answersLogoWhite

0


Best Answer

You can combine more than one condition with AND or with OR. How this is written depends on the particular programming language.

You can also have several cases; example in Java:

if (condition1)

{

command1;

}

else if (condition2)

{

command2;

{

else

{

command3;

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: For an if then else loop how do you include more than one condition?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are the components of loop?

a loop consist of data initialization;test condition;updation; example a for loop for(int a=1;a<5;a++) the loop will be executed 5 times four positives result and the last test condition will be failed and the loop will be exited there are many loops some of them are while loop,do...while loop,for loop,maybe more...... do while is an exit check loop and while and for are entry check loop.


What is the difference between entry and exit controlled loops - in Java?

while loop and for loop are entry controlled loops as they check looping condition at the entry point. do while loop is exit controlled loop as it checks looping condition at exit point. shreeradha@yahoo.com


When would you use a count controlled loop vs. a flag controlled loop?

Counter Loop:Counter loop is a loop which executes statement up to a fixed number of time.In GW FOR ... NEXT loop is used as counter loop.Controlled Loop:Controlled loop is used to extend the statements till a specific condition is satisfied. In GW WHILE ... WEND is used as controlled loop.


What are the merits and demerits of while loop and do while loop in c plus plus?

You use a while() loop when you want to test a condition before entering a loop for the first time, which may bypass the loop completely. The condition is also tested before beginning each iteration. A do..while() loop always executes the loop at least once, and tests the condition at the end of each iteration before beginning a new iteration.


What is difference between for loop and while loop?

One first basic rule is that you should use the for loop when the number of iterations is known. For instance:The loop iterates over the elements of a collection.The loop iterates over a range of values which is known in advance at execution time.The object provides a way to iterate over its elements with a for statements (e.g files).The while loop is the more general one because its loop condition is more flexible and can be more complicated than that of a for loop. The condition of a for loop is always the same and implicit in the construction. A for loop stops if there are no more elements in the collection to treat. For simple traversals or iterations over index ranges it is a good advice to use the for statement because it handles the iteration variable for you, so it is more secure than while where you have to handle the end of the iteration and the change of the iteration variable by yourself.The while loop can take every boolean expression as condition and permits therefore more complex end conditions. It is also the better choice if the iteration variable does not change evently by the same step or if there are more than one iteration variable. Even if you can handle more than one iteration variable in a for statement, the collections from which to choose the values must have the same number of elements.Note: In C 'for' and 'while' can be easily replaced by each other:while (exp) stmtfor (;exp;) stmtfor (exp1;exp2;exp3) stmt{ exp1; while (exp2) { stmt exp3}}

Related questions

Is a DOWHILE loop more flexible than a dountil loop?

No, they are equivalient. DO something WHILE condition; does the same thing as DO something UNTIL NOT condition;


Which loop is most fastest in c plus plus?

In terms of performance there is no difference whatsoever. Which version you use is usually decided by which is more appropriate for the type of loop you want to execute. for() loops allow you to combine an initial condition, a conditional expression and a loop expression in a single statement. The initial condition can include a declaration which falls from scope when the loop ends, but all expressions are optional. If a conditional expression is not declared, a conditional expression must appear in the body of the loop. while() loops are similar to for() loops, but are generally used when an initial condition and loop expression are not required, but a condition is. The condition is non-optional. do..while() loops are used when a loop must execute at least once, and a condition is not optional.


What is for looping in c language?

The for loop is another entry-controlled loop that provides a more concise loop control structure.The general form of the for loop isfor( initialization ; test condition ; increment ){body}Generally this loop is used when the either the no. of loops or the looping condition or the end condition is known.Ex.to count n no. of integers.Hope this will help.


What are the components of loop?

a loop consist of data initialization;test condition;updation; example a for loop for(int a=1;a<5;a++) the loop will be executed 5 times four positives result and the last test condition will be failed and the loop will be exited there are many loops some of them are while loop,do...while loop,for loop,maybe more...... do while is an exit check loop and while and for are entry check loop.


Compare While with for Statements?

The while loop is the more general one because its loop condition is more flexible and can be more complicated than that of a for loop. The condition of a for loop is always the same and implicit in the construction. A for loop stops if there are no more elements in the collection to treat. For simple traversals or iterations over index ranges it is a good advice to use the for statement because it handles the iteration variable for you, so it is more secure than while where you have to handle the end of the iteration and the change of the iteration variable by yourself.


What is the difference between entry and exit controlled loops - in Java?

while loop and for loop are entry controlled loops as they check looping condition at the entry point. do while loop is exit controlled loop as it checks looping condition at exit point. shreeradha@yahoo.com


When would you use a count controlled loop vs. a flag controlled loop?

Counter Loop:Counter loop is a loop which executes statement up to a fixed number of time.In GW FOR ... NEXT loop is used as counter loop.Controlled Loop:Controlled loop is used to extend the statements till a specific condition is satisfied. In GW WHILE ... WEND is used as controlled loop.


What are the merits and demerits of while loop and do while loop in c plus plus?

You use a while() loop when you want to test a condition before entering a loop for the first time, which may bypass the loop completely. The condition is also tested before beginning each iteration. A do..while() loop always executes the loop at least once, and tests the condition at the end of each iteration before beginning a new iteration.


What is difference between for loop and while loop?

One first basic rule is that you should use the for loop when the number of iterations is known. For instance:The loop iterates over the elements of a collection.The loop iterates over a range of values which is known in advance at execution time.The object provides a way to iterate over its elements with a for statements (e.g files).The while loop is the more general one because its loop condition is more flexible and can be more complicated than that of a for loop. The condition of a for loop is always the same and implicit in the construction. A for loop stops if there are no more elements in the collection to treat. For simple traversals or iterations over index ranges it is a good advice to use the for statement because it handles the iteration variable for you, so it is more secure than while where you have to handle the end of the iteration and the change of the iteration variable by yourself.The while loop can take every boolean expression as condition and permits therefore more complex end conditions. It is also the better choice if the iteration variable does not change evently by the same step or if there are more than one iteration variable. Even if you can handle more than one iteration variable in a for statement, the collections from which to choose the values must have the same number of elements.Note: In C 'for' and 'while' can be easily replaced by each other:while (exp) stmtfor (;exp;) stmtfor (exp1;exp2;exp3) stmt{ exp1; while (exp2) { stmt exp3}}


Why for loops is used?

The for loop is used when you want to do a procedure, a certain amount of times. The for loop is used when you already know how many times the loop will be repeated. for example... you want to scan an array. you can do something like this. for(i=0;i<myArray.length;i++){ if(myArray[i] == 5){ alert("This array position contains the number five."); } } the code above is javascript. But the idea is the same in any language. This is one use, but as I said. You use it when you already know the amount of times the loop will be repeated.


C plus plus for while loop example code?

The syntax for a for loop is:for (initialization; condition; increase) {statement;}for example:int arr[5] = {1, 2, 3, 4, 5};for (int i = 0; i < 5; i++) {cout


Why do you use looping statement in c language?

Usually the loop is used for repeating the same task for more than one time. If you don't give the terminating statement then the loop will go in infinite condition.