Skip to content
Home » C Program to Evaluate the Result of a Student

C Program to Evaluate the Result of a Student

Learn about C Program to Evaluate the Result of a Student in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

C Program to Evaluate the Result of a Student

mark1, mark2 and mark3 are the inputs from the user which corresponds to the marks scored in each subject. Then the total and average marks are calculated and final result is displayed. If the average is greater than 60 then first class result is displayed.

Program:

 #include<stdio.h>
 int main()
 {
   int mark1, mark2, mark3, total;
   float avg;

   printf("Enter marks of three subjects: ");
   scanf("%d %d %d",&mark1, &mark2, &mark3);

   if(mark1>=35 && mark2>=35 && mark3>=35)
   {
     total = mark1 + mark2 + mark3;
     avg = total/3;

     printf("Total marks scored = %d\n",total);
     printf("Average mark = %.1f\n", avg);

     if(avg>=60)
     {
       printf("first class.");
     }
     else
     {
       printf("second class.");
     }
   }
   else
   {
     printf("fail");
   }

   return 0;
 }

Output:

Enter marks of three subjects: 60 70 80
Total marks scored = 210
Average mark = 70.0
first class.

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Check Candidate is Eligible for Voting or Not in C
Finding Largest in Three Number in C