ICSE Class 10 Computer Applications Question 25 of 30

Solved 2023 Question Paper ICSE Class 10 Computer Applications — Question 25

Back to all questions
25
Question

Question 2(v)

Rewrite the following code using the if-else statement:

int m = 400;
double ch = (m>300) ? (m / 10.0) * 2 : (m / 20.0) - 2;
Answer
int m = 400;
double ch = 0.0;
if(m > 300)
    ch = (m / 10.0) * 2;
else
    ch = (m / 20.0) - 2;