top of page
Writer's pictureanitadevkar

Assignment No. 03 : Program to accept marks of five courses and compute the result.

Updated: Feb 1, 2022

Problem Statement: Write a program to accept marks of five courses and compute the result. If student scores aggregate greater than 75%, then the grade is distinction. If aggregate is 60>= and <75 then the grade is first division. If aggregate is 50>= and <60, then the grade is second division. If aggregate is 40>= and <50 then the grade is third division. If aggregate is < 40 then student is fail.


Program:

#include <stdio.h>

int main()

{

int maths,physics,chemistry,english,computer,total;

float per;

printf("Enter your marks (out of 100)\n");

printf("Enter Maths Marks:");

scanf("%d",&maths);

printf("Enter Physics Marks: ");

scanf("%d",&physics);

printf("Enter Chemistry Marks: ");

scanf("%d",&chemistry);

printf("Enter English Marks: ");

scanf("%d",&english);

printf("Enter Computer Marks: ");

scanf("%d",&computer);

total = maths+physics+chemistry+english+computer;

per = (total*100)/500;

printf("Total percentage is %0.2f%%\n",per);

if(per>=75)

printf("You have passed with Distinction \n");

else if(per>=60&&per<75)

printf("Your have passed with First Grade\n");

else if(per>=50&&per<60)

printf("Your have passed with Second Grade\n");

else if(per>=40&&per<50)

printf("Your have passed with Third Grade\n");

else if(per<40)

printf("You are Failed\n");

return 0;

}


Output:

Test case-1:

Enter your marks (out of 100)

Enter Maths Marks: 79

Enter Physics Marks: 76

Enter Chemistry Marks: 90

Enter English Marks: 78

Enter Computer Marks: 80

Total percentage is 80.00%

You have passed with Distinction

Test case-2:

Enter your marks (out of 100)

Enter Maths Marks:56

Enter Physics Marks: 55

Enter Chemistry Marks: 60

Enter English Marks: 45

Enter Computer Marks: 59

Total percentage is 55.00%

Your have passed with Second Grade

Test case-3:

Enter your marks (out of 100)

Enter Maths Marks:35

Enter Physics Marks: 39

Enter Chemistry Marks: 40

Enter English Marks: 34

Enter Computer Marks: 37

Total percentage is 37.00%

You are Failed


Steps:

  1. Accept input from user as five subject Marks

  2. Calculate percentage using formula.

  3. Check the condition and accordingly print the message.


91 views0 comments

Recent Posts

See All

C Program for pyramid of number

Program: #include <stdio.h> int main() { int i,j; for(i=5;i>0;i--) //for rows { for(j=1;j<=i;j++) //for columns j loop will iterate...

Program to print Triangle

Program: #include <stdio.h> int main() { int i,j; for(i=5;i>0;i--) //for rows { for(j=0;j<i;j++) //for columns j loop will iterate...

Comments


bottom of page