0
Why it is going into else block
Why this program is going into else block even when I entered marks grater tham 33 all the time Code : https://code.sololearn.com/cMi8wnlcpzFu/?ref=app
1 Réponse
+ 3
Bcoz of totalGrade, try printing value of totalGrade and you will understand. Your condition says if totalGrade > 40 but each time it evaluates to 0, hence, condition false and goes into else block.
Additionally, you don't have to check marks of every subject if you are checking totalGrade. If you have 33 marks in all, it won't go above 33.0% So no need of extra conditions. Just write like
if(totalGrade > 40).