Pages

Sunday, 28 January 2018

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.

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.
   
/* This program takes marks of a student in five subjects from user,
finds aggregate marks and percentage, and then shows results.*/
#include<stdio.h>
#include<conio.h>
int main ()
{
    /*Declaring and initializing veriables*/
    int sub1 = 0, sub2 = 0, sub3 = 0, sub4 = 0, sub5 = 0, aggmarks  = 0;
    float percentmarks = 0;
  
    /*Taking marks as input from the user*/
    printf("Plese enter the marks of the student in subject 1: ");
    scanf("%d",&sub1);
    printf("\nnow enter the marks of the student in subject 2: ");
    scanf("%d",&sub2);
    printf("\nnow enter the marks of the student in subject 3: ");
    scanf("%d",&sub3);
    printf("\nnow enter the marks of the student in subject 4: ");
    scanf("%d",&sub4);
    printf("\nnow enter the marks of the student in subject 5: ");
    scanf("%d",&sub5);
  
    /*Calculations*/
    aggmarks = sub1 + sub2 +sub3 +sub4 +sub5;
    percentmarks = (aggmarks/500.0)*100.0;
 
    /*Showing Results*/
    printf("\n________________________________________\n");
    printf("\nAggregate Marks of the Student are: %d \n",aggmarks);
    printf("\nwhich are %f percent of total marks.",percentmarks);
    getche();
    return 0;
}