Identify the appropriate conditional and/or iteration constructs for the given t
ID: 3825704 • Letter: I
Question
Identify the appropriate conditional and/or iteration constructs for the given tasks listed below and provide a brief discussion as to why this is the appropriate construct to use for this problem. a) You have an array that holds the names of people and you want to print out each person's name. b) You are asking the user to enter positive numbers using the keyboard. The user can enter as many positive numbers as she wants. You want to stop accepting numbers when the user enters the value -999. c You have a group of people and you want to count how many are in each of the following age groups: Under 20, 20-30, 30-45 and over 45. d) Your program uses a simple console menu as shown below and you need to process the menu selection. 1: View List of Employees 2 view Total Points For An Employee 3 Add New Employee 4 Add Attendance Point Entry 5 QuitExplanation / Answer
a)char names[20][100]
names array which accomodates 20 names and each name length 100
to print each name we can make use of for loop
for(i=0;i<20;i++)
printf("%s",names[i][]);
b)do-while loop
do
{
scanf("%d",&value);
}while(value!=-999);
c)declare a count variable for each group
suppose people age is array age[100]
for(i=0;i<100:i++)
{
if(age<20)
count1++;
if(age>20 && age<30)
count2++;
if(age>30 && age<45)
count3++;
if(age>45)
count4++;
}
d)while(1)
{
scanf("%d",&choice);
switch(choice)
{
case 1:
list();
break;
case 2:
print_employee();
break;
case 3:
add();
break;
case 4:
add_attendance();
break;
case 5:
exit(0);
}