60 368
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #67843 in C for abdul

Question #67843
i want program for output below;


Welcome to Children Camping Program

Name: Suzana
Age: 9
More participants (y/n)? y

Name: Alia
Age: 10
More participants (y/n)? y

Name: Farhan
Age: 10
More participants (y/n)? y

Name: Ali
Age: 15
More participants (y/n)? n

Total Participants
Kids : 3
Teenagers: 1
Expert's answer
/* users choice */
int kidsQuantity = 0; /* number of kids */
int teenagersQuantity = 0; /* number of teenagers */
char name[256];
int age;

printf("Welcome to Children Camping Program\n\n");

do {
printf("Name: ");
scanf("%s", name); /* getting name */
printf("Age: ");
scanf("%d", &age); /* getting age */

if (age < 13) {
kidsQuantity++;
} else if (age < 20) {
teenagersQuantity++;
}

printf("More participants (y/n)? ");
scanf(" %c", &choice); /* getting user choice */

printf("\n");
} while (choice == 'y');

/* displaying results */
printf("Total Participants\n");
printf("Kids: %d\n", kidsQuantity);
printf("Teenagers: %d\n", teenagersQuantity);

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions