Computer Science, asked by keeratdhami2027, 1 year ago

Convert the following if else if construct into switch case.

Answers

Answered by sumit00
0
I wanted to know if I could convert the following if else statement into a switch statement in c++. If I can could someone please tell me how, as currently I am getting errors the way I have written it.

This is the if else statement i am trying to convert into a switch statement.

if ( t>=10 && t <=18 ) { blue=0; green=1; red=1; xb_led=0; xg_led=1; xr_led=1; } else if ((t >18 && t<=22)||(t>22 && t<=25)) { green=0; blue=1; red=1; xg_led=0; xb_led=1; xr_led=1; } else { red=0; green=1; blue=1; xr_led=0; xg_led=1; xb_led=1; }

This is what I have converted it to but I get an error.

Similar questions