+ 14

Where difference between loop and if statement using for loop

Can please write code please

1st May 2019, 8:48 AM
vamsi krishna
vamsi krishna - avatar
6 Answers
+ 7
An if statement checks if an expression is true or false, and then runs the code inside the statement only if it is true. The code inside the loop is only run once... or it continues to execute the code however long the expression is true.
3rd May 2019, 2:56 AM
Md Shadab Alam
Md Shadab Alam - avatar
+ 3
If statements are to implement choice. Loops are to implement repetitions.
3rd May 2019, 2:14 AM
Sonic
Sonic - avatar
+ 1
Statements in an if structure, should not loop or be performed more than once. Statements in a Loop structure repeat until a condition is met
2nd May 2019, 6:02 PM
Miguel delRio
Miguel delRio - avatar
+ 1
An if statement checks its condition once, but a loop can possibly check its conditional many times. int num = 100; if ( num > 5 ) { //The conditional num>5 // is checked exactly once } while ( num < 103 ) { num++; //add 1 to num //The conditional num <=105 // is checked 4 times— // when num = 100, 101, 102 // and 103. The while block // won’t run when num = 103 } while ( num > 1 ) { num = num + 1; num = num - 1; //An infinite loop } for ( int i = 0; i < 10; i++ ) { //The conditional i < 10 is // checked 10 times. }
4th May 2019, 2:01 AM
ic01010101 ◼️LM
ic01010101 ◼️LM - avatar
- 1
hello add egg to waffles
3rd May 2019, 11:13 AM
Freddie Jones
Freddie Jones - avatar