Saturday 15 October 2011

(c) 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;
}


4 comments:

  1. #include
    main()
    {
    int s1,s2,s3,s4,s5,agg;
    float percent;
    printf("enter the marks obtained by the student in every subject");
    scanf("%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5);
    agg=s1+s2+s3+s4+s5;
    percent=agg/5;
    printf("%f",percent);

    why isn't this working

    ReplyDelete
    Replies
    1. Beacause
      Agg=(Total obtained marks)/(total marks)
      Percent =Agg*100

      Delete
  2. #include
    int main()
    {
    int sub1,sub2,sub3,sub4,sub5,agg,per;
    printf("Enter your sub1=\n");
    scanf("%d",&sub1);
    printf("Enter your sub2=\n");
    scanf("%d",&sub2);
    printf("Enter your sub3=\n");
    scanf("%d",&sub3);
    printf("Enter your sub4=\n");
    scanf("%d",&sub4);
    printf("Enter your sub5=\n");
    scanf("%d",&sub5);
    agg=(sub1+sub2+sub3+sub4+sub5)/5;
    printf("agg=%d\n",agg);
    per=agg*100%
    printf("per=%d",per);

    return 0;
    }
    Solve this

    ReplyDelete
  3. 7. If marks obtained by a student in 5 different subjects are input from keyboard, find out the aggregate marks and percentage marks obtained by the student.
    solve it

    ReplyDelete