PLAY WITH CODING

Home Basic Program If & Else Loops Conversion Pattern logo

Basic C Program

program to calculate total marks and percentage of five subject

Input - Output

Input
Enter marks of five subject: 77 89 72 82 62

Output
total marks= 382

percentage= 76.4 %

Algorithm

Step 1: START

Step 2: Input marks of five subject.

Step 3: Calculate total marks .

Step 4: Calculate percentage i.e ((total * 5)/100).

Step 5: END

CODE


/* Calculate marks and percentage of five subject*/

#include <stdio.h>
int main()
{
      int english,hindi,math,science,computer,total;
      float percentage;
      printf("Enter the marks of five subjects : ");
      scanf("%d%d%d%d%d",&english,&hindi,&math,&science,&computer);
      total = english + hindi + math + science + computer;
      percentage= (total*100)/500;
      printf("total marks = %d\n",total);
      printf("percentage = %f%%",percentage);
    return 0;
}


/* Calculate marks and percentage of five subject*/

#include <iostream>
using namespace std;
int main()
{
      int english,hindi,math,science,computer,total;
      float percentage;
      cout<<"Enter the marks of five subjects : ";
      cin>>english>>hindi>>math>>science>>computer;
      total = english + hindi + math + science + computer;
      percentage= (total*100)/500;
      cout<<"total marks = "<<total;
      cout<<"\npercentage = "<<percentage<<"%";
    return 0;
}

OutPut

Enter marks of five subject: 77 89 72 82 62

total marks = 382
percentage = 76.4 %