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
7 Antworten
+ 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'
+ 1
Oh like a char character thank bro
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;}
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.
0
Muhammad Abdullah Kindly compare and check your mistakes.
Do not commit these next time.
https://code.sololearn.com/cgS6fXgbj73r/?ref=app
0
I am assigning A and B itself to res
0
Oka thanx