C Program To Take Input In Three Subjects Physics, Chemistry And Math’s And Calculate The Total And Percentage.

Q15. Write a C program to take input in three subjects Physics, Chemistry and Math’s and calculate the total and percentage.

Solution:

#include<stdio.h> //standard input/output header file

#include<conio.h> //for clrscr()

 

int main()

{

int Phy,Chem,Maths,total,per;

 

clrscr(); //for clearing the screen

 

printf(“\n Enter the marks of Physics: “);

scanf(“%d”,&Phy);

printf(“\n Enter the marks of Chemistry: “);

scanf(“%d”,&Chem);

printf(“\n Enter the marks of Math’s: “);

scanf(“%d”,&Maths);

 

total=Phy+Chem+Maths;

per=total/3;

 

printf(“\n Total= %d”,total);

printf(“\n Percentage= %d%”,per);

 

getch(); //holds the screen until any key is pressed

return 0; //makes main() finish

}

 

OUTPUT:

Enter the marks of Physics: 78

Enter the marks of Chemistry: 89

Enter the marks of Math’s: 90

Total= 257

Percentage= 85%

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: