Program to enter marks of five subject and find their sum and percentage

Write a program to enter marks of five subjects and find their sum and percentage.

C Program

#include <stdio.h>
int main()
{
    int englishMarks;
    int hindiMarks;
    int physicsMarks;
    int chemistryMarks;
    int mathsMarks;

    printf("Enter marks of English : ");
    scanf("%d", &englishMarks);

    printf("Enter marks of Hindi : ");
    scanf("%d", &hindiMarks);

    printf("Enter marks of Physics : ");
    scanf("%d", &physicsMarks);

    printf("Enter marks of Chemistry : ");
    scanf("%d", &chemistryMarks);

    printf("Enter marks of Maths : ");
    scanf("%d", &mathsMarks);

    int sum = (englishMarks + hindiMarks + chemistryMarks + physicsMarks + mathsMarks);
    float percentage = ((float)(sum) / 500) * 100;
    printf("Sum of marks are %d\n"sum);
    printf("Percentage of marks is %lf\n"percentage);
    return 0;
}

Input:

Enter marks of English : 56
Enter marks of Hindi : 67
Enter marks of Physics : 78
Enter marks of Chemistry : 64
Enter marks of Maths : 72

Output:

Sum of marks are 337
Percentage of marks is 67.400002


No comments:

Post a Comment