Student’s marks in three subjects (out of 100) and prints the percentage marks.

Q20. Write a C++ program that inputs a student’s marks in three subjects (out of 100) and prints the percentage marks.

Ans.

#include<iostream.h>

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

int main()

{

clrscr();  //for clear screen

float sub1,sub2,sub3,marks,perc;

cout<<“Enter marks obtained in 3 subjects:”;

cin>>sub1>>sub2>>sub3;

marks=sub1+sub2+sub3;

perc=(marks/300)*100;

cout<<“\n”<<“The percentage marks are:”<<perc<<“%”;

return 0;

}

 

 

Leave a Reply

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