Rewrite the following code using the if-else statement:

ICSE Class 10 Computer Applications PYQ · 2023 Paper · Section A

2(v)1 Mark · 2023 · Section A · 2023 Paper

Rewrite the following code using the if-else statement:

int m = 400;
double ch = (m>300) ? (m / 10.0) * 2 : (m / 20.0) - 2;
Show SolutionHide Solution↓
int m = 400;
double ch = 0.0;
if(m > 300)
    ch = (m / 10.0) * 2;
else
    ch = (m / 20.0) - 2;
← Previous questionNext question →

Browse the free Computer Applications sample bank