0

What's if statement nd for statement

m new

6th Aug 2017, 4:04 PM
Ashwani Rautela
Ashwani Rautela - avatar
2 Respuestas
9th Jun 2021, 8:41 AM
Tharul Nejana
Tharul Nejana - avatar
- 2
if statements check a condition. if it is true, they carry out a task. if false they move on. example: if(2>1){ If 2 is bigger than one, run the code here. } if(1>2){ if 1 is bigger than 2, run this code. if it is not true, move on. } for is the beginning of a for loop. they are loops with a limited amount of runs. example for(int i=0; i<5; i++){ run this code until the variable i is no longer smaller than 5 } we declare a for loop. inside the ( ) we declare a variable i as an integer. then we declare the condition for the loop. in this case we run the loop if i is less than 5. then we increase i by 1. This keeps track of how many times the loop has run. inside the loop we put code that we run repeatedly until the loop stops
6th Aug 2017, 4:28 PM
LordHill
LordHill - avatar