Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) Convert the \"Switch\" statement to \"if/else\" 2) Convert from for loop to w

ID: 3916369 • Letter: 1

Question

1) Convert the "Switch" statement to "if/else"

2) Convert from for loop to while loop

Convert the following "switch" statement to an equivalent "if/else": switch(x) case 10: cost- 1; break; case 20: cost- 2; break; default: cost 0; 0 if (cost =-1) x = 1; else if (cost-20) x = 2; else x = 0; O if ( x = 10) cost = 1; else if (x = 2) cost-20; else cost = 0; if (case10) cost 1; else if (case 20) cost- 2; else cost-0 if (cost1) case- 10; else if (cost 2) case 20; else cost 0; if (x10) cost 1; else if (x20) cost 2; else cost 0;

Explanation / Answer

1) E (Last Option)

if(x==10) cost = 1 else if(x==20) .. . .. . .. .. . ..


2) B

int k = 0;
while (k < 10) {
cout<<k;
k++;

}



Thanks, PLEASE UPVOTE if helpful