#include
#include
int main()
{
clrscr();
float sub1,sub2,sub3,sub4,sub5,perc,total;
cout<<“\n\t Enter the Marks obtained in 5 Subjects:”;
cin>>sub1>>sub2>>sub3>>sub4>>sub5;
total=sub1+sub2+sub3+sub4+sub5;
perc=(total/500)*100;
cout<<“\n The Percentage marks are:”<<perc<<“%”;
return 0;
}
#include
int main()
{
clrscr();
float sub1,sub2,sub3,sub4,sub5,perc,total;
cout<<“\n\t Enter the Marks obtained in 5 Subjects:”;
cin>>sub1>>sub2>>sub3>>sub4>>sub5;
total=sub1+sub2+sub3+sub4+sub5;
perc=(total/500)*100;
cout<<“\n The Percentage marks are:”<<perc<<“%”;
return 0;
}
if marks are of type integer then this code does not gives desired result…
thanks 🙂
i need to get 100 numbers from user then want to total that
how to get cin 100 number
You need to write a while-loop where you will make the user to type an integer X times(in your case 100) as needed.
try using arrays