C Program to Calculation of Total and Percentage

How to write a C Program to Calculation of Total and Percentage in C Programming Language ?


Solution:

Calculates the total and percentage of the marks obtained in five subjects by a student. The marks obtained are to be entered by the student.

If the marks obtained by a student in five different subjects are input through the keyboard, find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be obtained by a student in each subject is 100.

  1. #include<stdio.h>
  2. main()
  3. {
  4.  
  5. int m1, m2, m3, m4, m5, total;
  6. float percentage;
  7.  
  8. printf ("Enter the marks obtained by the student in all the five subjects: ");
  9. scanf ("%d %d %d %d %d", &m1, &m2, &m3, &m4, &m5);
  10.  
  11. total= m1+m2+m3+m4+m5;
  12. percentage = total/5;
  13.  
  14. printf ("\nThe aggregate marks obtained by the student are: %d", total);
  15. printf ("\nThe percentage obtained by the student are %f", percentage);
  16.  
  17. }


Learn More :