Every switch statement can be rewritten as a series of


1. What is the difference between a while loop and a do..while loop?

2. Every switch statement can be rewritten as a series of nested if statements. Is the reverse true? Give an example of a set of nested loops that could not be implemented as a switch statement?

3. State what output, if any, results in each of the following code segments, use a trace table to show the execution of the loops:

int i=5;

int sum = 0;

while (i>=0){

sum = sum + i 2; i--;

System.out.println(sum);

b. int x, y;

do

System.out.println(x , " + y); x=x+1;

while (x

SycstefV.oluntt.pirin't((ii'5-5)--V(*** ");

}

System.out.println();

fc.(1 = i; <= 3; I-'){ System.out.print("*");

System.out.println();

4. Rewrite the while loop in question 3a as a for loop AND rewrite the for loop in question 3c as a while loop

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Every switch statement can be rewritten as a series of
Reference No:- TGS01140948

Now Priced at $20 (50% Discount)

Recommended (96%)

Rated (4.8/5)