Answer to Question #3235 in C for MUGABO Gustave

Question #3235
Write a C program to read marks of a student for 3 subjects (Math, Chemistry and Computer Science) from keyboard. The program should calculate the total and average marks for the student.
1
Expert's answer
2011-07-01T18:13:47-0400
#include <stdio.h>
#include <conio.h>

char get_user_answer();

int main()
{
int markForMath, markForChemistry, markForCompScience;
do
{
& int total;
& system("cls");
& printf("Enter the mark for Math: ");
& scanf("%d", &markForMath);
& printf("Enter the mark for Chemistry: ");
& scanf("%d", &markForChemistry);
& printf("Enter the mark for Computer Science: ");
& scanf("%d", &markForCompScience);
& total = markForMath + markForChemistry + markForCompScience;
& printf("The total mark: %d\n", total);
& printf("The average mark: %.2f\n", (float)total / 3);
}
while (get_user_answer() != 'n');
return 0;
}

char get_user_answer()
{
char answer;
printf("Repeat calculations? (y/n)");
do
{
& answer = getch();
}
while (tolower(answer) != 'n' && tolower(answer) != 'y');
return answer;
}

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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS