Write a program that calculates the marks of 5 subject of 03 students
this is question n i,ve done this but there is some little bit problem so plz help me here i give blew source code problem is that when output comes 4260096 print this number also dont know where its come from so i add return 0;
now its give 0 in ouput window :(
#include<iostream.h>
int phy,chm,eng,mat,ps;
int marks()
{
float grade;
cout<<"total marks is "<<phy+chm+eng+mat+ps<<"\n";
grade=(((phy+chm+eng+mat+ps)*100)/500);
{
if (grade<=100&&grade>=85 )
cout <<"grade is A+\n";
if (grade <=84&&grade>=75)
cout <<"grade is A\n";
if (grade<=74&&grade >=65)
cout <<"grade is B\n";
if (grade<=64&&grade>=55)
cout <<"grade is C \n";
if (grade <=54)
cout <<"grade is fail \n ";
}
return 0;
}
int student1()
{
cout<<"Enter marks of student#1 \n";
cout << "Enter marks of physics";
cin>>phy;
cout << "Enter marks of chemistry";
cin >>chm;
cout <<"Enter marks of english";
cin>>eng;
cout <<"enter marks of maths";
cin>>mat;
cout <<"Enter marks of pakistan studies";
cin>>ps;
cout << marks()<<"\n" ;
return 0;
}
int student2()
{
cout<<"Enter marks of student#2 \n";
cout << "Enter marks of physics";
cin>>phy;
cout << "Enter marks of chemistry";
cin >>chm;
cout <<"Enter marks of english";
cin>>eng;
cout <<"enter marks of maths";
cin>>mat;
cout <<"Enter marks of pakistan studies";
cin>>ps;
cout << marks()<<"\n" ;
return 0;
}
int student3()
{
cout<<"Enter marks of student#3 \n";
cout << "Enter marks of physics";
cin>>phy;
cout << "Enter marks of chemistry";
cin >>chm;
cout <<"Enter marks of english";
cin>>eng;
cout <<"enter marks of maths";
cin>>mat;
cout <<"Enter marks of pakistan studies";
cin>>ps;
cout << marks()<<"\n" ;
return 0;
}
main()
{
cout<< student1();
cout<< student2();
cout<< student3();
return 0;
}
Please re-submit your code using the [ code ] [ /code ] function. That will give you some line numbers to work with and is easier for us to read to help you.
The reason it is displaying 0 because you are returning "0" as the total for each function. You will want to return the marks of each student instead of returning 0.