/* Program to calculate the final grade */ #include <stdio.h> int main() { int l
ID: 3793776 • Letter: #
Question
/* Program to calculate the final grade */
#include <stdio.h>
int main()
{
int lab1, lab2, lab3, lab4, lab5;
int quiz1, quiz2, quiz3, quiz4;
int project1, project2, project3;
int midtermGrade, finalExam;
int totalLab, totalQuiz, totalProject, totalMid, totalFinal;
int totalOverall;
printf ("Enter first lab grade: ");
scanf("%d", &lab1);
printf ("Enter second lab grade: ");
scanf("%d", &lab2);
printf ("Enter third lab grade: ");
scanf("%d", &lab3);
printf("Enter fourth lab grade: ");
scanf("%d", & lab4);
printf("Enter fifth lab grade: ");
scanf("%d", &lab5);
totalLab = (lab1 + lab2 + lab3 + lab4 + lab5) / 5;
printf("The lab total is: %d ", totalLab);
printf("Enter first quiz: ");
scanf("%d", &quiz1);
printf("Enter second quiz: ");
scanf("%d", &quiz2);
printf("Enter third quiz: ");
scanf("%d", &quiz3);
printf("Enter fourth quiz: ");
scanf("%d", &quiz4);
totalQuiz = (quiz1 + quiz2 + quiz3 + quiz4) / 4;
printf("The quiz total is: %d ", totalQuiz);
printf("Enter first project: ");
scanf("%d", &project1);
printf("Enter second project: ");
scanf("%d", &project2);
printf("Enter third project: ");
scanf("%d", &project3);
totalProject = (project1 + project2 + project3) / 15;
printf("The total project is %d", totalProject);
printf(" Enter your midterm grade: ");
scanf("%d", &midtermGrade);
totalMid = midtermGrade / 5;
printf("Your midterm total is %d", totalMid);
printf(" Enter your final exam grade: ");
scanf("%d", finalExam);
totalFinal = finalExam / 5;
printf("Your final exam score is %d ", totalFinal);
totalOverall = (totalLab + totalQuiz + totalProject + totalMid + totalFinal);
printf(" Your overall score from 0-100 is: %d", totalOverall);
return 0;
}
Most of the program worked until i put the totalOverall, so where did i go wrong
Explanation / Answer
Hi
I have fixed the issue and highlightd the code changes below. '&' is missing.
#include <stdio.h>
int main()
{
int lab1, lab2, lab3, lab4, lab5;
int quiz1, quiz2, quiz3, quiz4;
int project1, project2, project3;
int midtermGrade, finalExam;
int totalLab, totalQuiz, totalProject, totalMid, totalFinal;
int totalOverall;
printf ("Enter first lab grade: ");
scanf("%d", &lab1);
printf ("Enter second lab grade: ");
scanf("%d", &lab2);
printf ("Enter third lab grade: ");
scanf("%d", &lab3);
printf("Enter fourth lab grade: ");
scanf("%d", & lab4);
printf("Enter fifth lab grade: ");
scanf("%d", &lab5);
totalLab = (lab1 + lab2 + lab3 + lab4 + lab5) / 5;
printf("The lab total is: %d ", totalLab);
printf("Enter first quiz: ");
scanf("%d", &quiz1);
printf("Enter second quiz: ");
scanf("%d", &quiz2);
printf("Enter third quiz: ");
scanf("%d", &quiz3);
printf("Enter fourth quiz: ");
scanf("%d", &quiz4);
totalQuiz = (quiz1 + quiz2 + quiz3 + quiz4) / 4;
printf("The quiz total is: %d ", totalQuiz);
printf("Enter first project: ");
scanf("%d", &project1);
printf("Enter second project: ");
scanf("%d", &project2);
printf("Enter third project: ");
scanf("%d", &project3);
totalProject = (project1 + project2 + project3) / 15;
printf("The total project is %d", totalProject);
printf(" Enter your midterm grade: ");
scanf("%d", &midtermGrade);
totalMid = midtermGrade / 5;
printf("Your midterm total is %d", totalMid);
printf(" Enter your final exam grade: ");
scanf("%d", &finalExam);
totalFinal = finalExam / 5;
printf("Your final exam score is %d ", totalFinal);
totalOverall = (totalLab + totalQuiz + totalProject + totalMid + totalFinal);
printf(" Your overall score from 0-100 is: %d", totalOverall);
return 0;
}
Output:
Your overall score from 0-100 is: 6
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.