answersLogoWhite

0


Best Answer

Because you have to repeat something. (Or you can use while-loop, too.)

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why you use for loop inside switch statement?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering
Related questions

Can a continue statement be used in a switch statement?

If you have a loop in your switch statement or around your switch statement, you can use the continue statement in that. You cannot use a continue statement outside of a loop (do, for, or while).


Can break statement be used without any loop?

The Break statement should generally get executed in some loop or switch statement. The below code will give compiler error. void main() { printf("12"); break; printf("14"); }


Why you use if loop in telecoms?

No such thing as if-loop. if-else statement is not a loop.


What is the difference between 'switch' statement and 'if' statement?

we can use switch statement in multiple time but in if statement we can not use multiple time


Why break statement is optional in c plus plus?

You use a break statement to end execution of the enclosing iterator (loop) or switch statement. If omitted at the end of a case label, execution continues to the next case label, including the default case, until a jump statement is encountered (break, goto or return) or the switch statement falls from scope. Sometimes this can be desirable behaviour, thus the use of break is optional. A break statement is always optional at the end of the default case, or the last case label. Its usage in loops is always optional, to allow a loop to end prematurely regardless of the conditional expression that controls the loop.


Why you use while function in c?

It is a statement; you can create a loop with it: while (<condition>) <statement>


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;)


What is the difference between while dowhile?

While: If we can use while statement it will check the condition then proceed further loop statement.DoWhile: If we use dowhile, first execute loop statement then check the condition.


Difference between break and continue statements in wml?

Break statements:-its terminates the current while or for loop and continue the program execution from the statement following the terminated.NOTE:-note that it is wmlscript syntax error to use the break statement outside of while or a for statements.example;Breakstatement:Break;Continue statement:-this statement terminate execution of a block of statementin while or for loop and continues execution of loop with the next iteration.note that the continue statement does not terminate the execution of loop and also is wmlscript syntax error to use the break statement outside of while or a for statements.-> in while loop, it jumps back to the condition.-> in for loop,it jumpsto the update expression.syntax:continuestatement:continue;


How can a loop be structured so that it terminates a statement in the middle of its block?

I think you want to use statement break.


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

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


How do you use logic inside switch statement?

Nothing special, eg:switch (c) {case 'A':/* use any 'logic' you want */break;default:/* use any 'logic' you want */}