C program to calculate total average and percentage of five subjects
C Programming Language Fundamentals of C Language (Article) Fundamentals of C Language (Program)
3327Program:
/** * C program to calculate total, average and percentage of five subjects */ #include"stdio.h" int main() { float n1, n2, n3, n4, n5; float total, average, percentage; // Read marks of all five subjects printf("Enter marks of five subjects: \n"); scanf("%f%f%f%f%f", &n1, &n2, &n3, &n4, &n5); // Calculate total, average and percentage one by one total = n1 + n2 + n3 + n4 + n5; average = total / 5.0; percentage = (total / 500.0) * 100; // Print the result printf("Total marks = %.2f\n", total); printf("Average marks = %.2f\n", average); printf("Percentage = %.2f \n", percentage); return 0; }
Output:
Enter marks of five subjects: 1 2 3 4 5 Total marks = 15.00 Average marks = 3.00 Percentage = 3.00Press any key to continue . . .
This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.