What is the value of beta after the following code executes

What is the value of beta after the following code executes if the input is 5

a)16
b)11
c)7
d)20

int beta; cin >> beta; switch (beta) case 5: case 1: case 5: beta += 5; betat+ beta += 5; break; case 4: beta += 4;

Solution

Answer will be 16.

because input is 5, first it will flow in case 5 and now the value of beta is 10.

because there is no break statement after case 5 it will flow to case 1 and now the vlue of beta is 11 and after that it will flow to case 5 andnow the value of beta is 16. after that there is \"break;\" condition so it will exit the switch case.

so value of beta is 16.

What is the value of beta after the following code executes if the input is 5 a)16 b)11 c)7 d)20 int beta; cin >> beta; switch (beta) case 5: case 1: case

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site