answersLogoWhite

0

one or more

User Avatar

Wiki User

11y ago

What else can I help you with?

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.


Differences between if else and while loop?

Easy: if-else is not a loop; while, for and do-while are loops.if-else just run once, but do-while run many times.


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.


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


What is the while loop in C programming?

"while" is an entry controlled loop statement i.e the condition is evaluated first and if it is true the body of the loop is evaluated.This process is repeated until the test condition is false;then the control is transfered out of the loop. The general form of while is as following syntax: while (<condition>) { <statements>; }

Related Questions

What is the difference between if and while loop?

Easy: if-else is not a loop; while, for and do-while are loops.if-else just run once, but do-while run many times.


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.


Differences between if else and while loop?

Easy: if-else is not a loop; while, for and do-while are loops.if-else just run once, but do-while run many times.


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.


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


Describe two different forms of looping?

For loop: A for loop is a control flow statement that repeats a block of code a set number of times based on a predefined condition. It is commonly used when you know in advance how many iterations are needed. While loop: A while loop is another control flow statement that repeats a block of code as long as a specified condition is true. It is useful when you do not know in advance how many times the code needs to be executed.


How many times can you tolerate a quadratic loop?

4


How many times does a for loop run in a typical iteration?

A for loop typically runs a specific number of times in each iteration, as determined by the loop's initialization, condition, and increment/decrement statements.


How many times would the for loop execute in the following code snippet?

The for loop would execute 10 times in the following code snippet.


How many times does the following loop execute Set x equals 1 Until x 7?

6 times. When x is 7, the loop ends.


What is the while loop in C programming?

"while" is an entry controlled loop statement i.e the condition is evaluated first and if it is true the body of the loop is evaluated.This process is repeated until the test condition is false;then the control is transfered out of the loop. The general form of while is as following syntax: while (<condition>) { <statements>; }


Which is more good to use for loop or while loop?

The main difference comes into picture when you use continue with them i.e. for and while. In a while loop if continue is used before the increment of a variable is done it converts into a infinite loop. i=1; while(i<10) { /* do stuff */ if(i==6); continue; i++; } The above piece of code will turn into an infinite loop. for(i=1;i<10;i++) { /* do stuff */ if(i==6); continue; } In the above for loop the value of will be incremented once it attains the value 6. Therefore it will not turn into a infinite loop. Cheers. astvansh> 'for' statement takes the start condition, stop condition, and the increment. 'while' statement just takes the stop condition. One scenario (which i can think of) where while 'needs' to be used rather than a for, would be when the counter needs to be incremented/decremented conditionally... string[] arr = {"a", "b", "b", "c"}; int i = 0; while( i< 10) { // do something constructive if(arr[i] == "b") { i = i + 2; } else { i++; } } Cheers, Ajeesh Another main difference between the two: a 'for' loop is called a determinate loop, meaning that we usually use it when we know ahead of time how many iterations we want. The 'while' loop is an 'indeterminate' loop, because we usually use it in situations where we do not know the number of times the loop may iterate.