0

I need help in debugging a code

It is a program that shows the output based on marks obtained by students using switch statement

2nd Dec 2019, 11:35 AM
Muhammad Abdullah
Muhammad Abdullah - avatar
7 Réponses
+ 1
Muhammad Abdullah yes you are assigning them. but you declared them above as int without any value. if you want A, B themselves use 'A', 'B'
2nd Dec 2019, 12:13 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 1
Oh like a char character thank bro
2nd Dec 2019, 12:17 PM
Muhammad Abdullah
Muhammad Abdullah - avatar
0
int quiz,assign,mid,final,avg,re,res,A,B,C,D,F; cout << "Enter your quiz marks: "<<endl; cin >> quiz; cout << "Enter your assignment marks: "<<endl; cin >>assign; cout << "Enter your mids marks: "<<endl; cin >>mid; cout << "Enter your finals marks: "<<endl; cin >>final; avg = (quiz+assign+mid+final)/4; re = (avg/100)*100; { if (re>=80) res = A; else if (re>=60) res = B; else if (re>=50) res = C; else if (re>=40) res = D; else if (re<40) res = F; } switch (re) { case 1: if (res==A) cout<< "Excellent"; break; case 2: if (res==B) cout<< "Good"; break; case 3: if (res==C) cout<< "Average"; break; case 4: if (res==D) cout<< "Poor"; break; case 5: if (res==F) cout<<"Fail"; break;}
2nd Dec 2019, 11:35 AM
Muhammad Abdullah
Muhammad Abdullah - avatar
0
in the if statements. res = A, res = B... those letters are not initialized anywhere they don't have any value and you are assigning them to res.
2nd Dec 2019, 11:49 AM
Bahhaⵣ
Bahhaⵣ - avatar
0
Muhammad Abdullah Kindly compare and check your mistakes. Do not commit these next time. https://code.sololearn.com/cgS6fXgbj73r/?ref=app
2nd Dec 2019, 11:51 AM
Avinesh
Avinesh - avatar
0
I am assigning A and B itself to res
2nd Dec 2019, 12:09 PM
Muhammad Abdullah
Muhammad Abdullah - avatar
0
Oka thanx
2nd Dec 2019, 12:09 PM
Muhammad Abdullah
Muhammad Abdullah - avatar