64 609
Assignments Done
99,1%
Successfully Done
In September 2018

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.
Expert's answer
#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions