Pages

Thursday, December 1, 2011

C Programming to calculate total and percentage of 5 subjects ( Short Way )


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

No comments:

Post a Comment