0
Please need your help
question were given to me at school i should write a program that accept CA and exams of a student using switch statement and determine his grade 70-100 Grade='A' 60- 69 grade='B' 50- 59 grade='C' 45- 49 grade ='D' >=44. grade='F' while solving this problem i am litle bit confuse with the switch statement e.g int ca,exam,total; cin>>ca>>exam; total=ca+exam; switch(total){ case <=44: grade='F'; break; case >=45: grade='D' break; and so on, but unfortunately its not working please help me solve this problem
6 odpowiedzi
+ 2
Faisal Hamman Adama Muhammad you cannot have case as condition...it must have value...I.e. case 4: not like case <4:
+ 2
you can club cases if it's required as below to achieve the same:
case 1:
case 2:
case 3 :
case 4:
// do some stuff for case as 1 to 4
case 5:
//do stuff for case 5
default:
//do stuff for rest all scenario
+ 1
i know that i omitted the cout but my main problem is the case
0
hi ,
Aren't cout<< or cin>> are missing after each case ?
0
thank you bro! i am greatful but from the instruction of the question we are not allow to use if statement