answersLogoWhite

0

While is NOT a replacement for SWITCH -- CASE

However , still if this is the requirement then , you can do this :

While (1)

{

if (case1 ) {}

if (case2 ) {}

:

:

:

if (case n ) {}

if (case default ) {}

} //end of while loop

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

What is difference between select Case statement and nested loop in c programming in UNIX?

UNIX has no bearing on the C language; it is cross-platform. There is no select/case in C, you probably meant switch/case. However, a switch/case is a conditional jump while a nested loop is a loop within a loop. Besides the C language they have nothing in common with each other.


What type of loop uses a boolean expression?

A "while" loop is appropriate in this case - one in which the condition is evaluated at the beginning of the loop.


Is it possible to use a for loop in place of a while loop?

Yes. while loop consist of only condition statement to make for loop look as while loop we can use syntax shown below: for(;condition;) eg: for(;i<=n;)


Difference between for and while statements in java?

Both for and while belongs to repetitive controls structure. for is used when a user does not know how manytimes the looping needs to be executed i.e. infinite in some cases.Also in case of for initialization,condition and step decrement/ increment can take place in a single loop. In viceversa case while is used. In case of while we first check the condition if it is satisfied , only then execute the statements present below the loop. Both for and while belongs to repetitive controls structure. for is used when a user does not know how manytimes the looping needs to be executed i.e. infinite in some cases.Also in case of for initialization,condition and step decrement/ increment can take place in a single loop. In viceversa case while is used. In case of while we first check the condition if it is satisfied , only then execute the statements present below the loop.


Is possible to use a for loop in place of a while loop?

Yes, it's easy:Old: while (expression)statementNew: for (; expression;)statement


Difference between while and do while loops in java?

The most important differences are: a. The while loop starts with a condition whereas the condition is the line of code in case of a do while loop b. The do while loop is guaranteed to run the loop body atleast once even if the condition is an impossible to satisfy but such a guarantee is not available with the normal while loop


What is the equivalence of for and while loops?

The For loops and While loops are similar in functionality aspects. They perform a specified set of instructions repeatedly until a certain condition is met. The only difference being, the loop variable modification happens in the for loop declaration whereas in case of a while loop, we must include it in the block of code within the loop. Ex: For Loop: for(int i=0; i<10;i++){ ... } While Loop: int i = 0; while(i < 10){ i++ ... } If you see the code the variable initialization, modification happens in the same line for a For loop whereas in case of a while loop we do it in separate lines of code.


What is main different between do while and while?

If you want to execute a statement which is in while loop at least one time you can use do- while loop. this is why because initially first statements will be executed then condition will be checked. but in case of while first condition will be check then statements will be executed


What is a nested loop in java?

A nested loop is a (inner) loop that appears in the loop body of another (outer) loop. The inner or outer loop can be any type: while, do while, or for. For example, the inner loop can be a while loop while an outer loop can be a for loop.


What are the similarities of while loop and a do while loop?

They both loop


Which pair of loops causes a statement or set of statements to repeat as long as a condition is true?

A while loop repeats until the condition becomes false, and may never execute: int a = 4; while (a > 5) { //Do something } or int a = 4; while (a > 0) { //Do something a--; }


What time of loop is used when you know how many times the loop instructions should be processed?

It's best to use a for loop.For example, if you want 10 iterations:for (int i = 1; i