4260096 in output dont know where come from :(

closed account (EwCiz8AR)
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 :(



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#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;
}

Last edited on
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.
1
2
3
4
5
6
int main() {
student1();
student2();
student3();
return 0;
}


You don't need to cout those functions they seem to handle their own console output.

Also your main needs to be int main

And your grade is a float but you pass in all ints when you calculate it did you mean to do that?
Last edited on
Topic archived. No new replies allowed.