Pages

Wednesday, November 30, 2011

C Programming to calculate total and percentage of 5 subjects

/*calculate total and percentage of 5 subjects */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int S1,S2,S3,S4,S5;
    float t,p;
    printf("Enter marks in subject one: ");
    scanf("%d",&S1);
    printf("Enter marks in subject two: ");
    scanf("%d",&S2);
    printf("Enter marks in subject three: ");
    scanf("%d",&S3);
    printf("Enter the marks in subject four: ");
    scanf("%d",&S4);
    printf("Enter the marks in subject five: ");
    scanf("%d", &S5);
    t=S1+S2+S3+S4+S5;
    p=t/500*100;
    printf("the total of all subjects=%f",t);
    printf("\nthe percentage of all subjects=%f",p);
    system("pause");
    return 0;
}

No comments:

Post a Comment