The three things inside the for loop are separated by
Answers
The three things inside the for loop are separated by - Comma, Semicolon, and parenthesis mark.
- The for loop is a conditional iterative statement in a programming language that is used to check for particular criteria and then executes a block of c ode continuously as long as those conditions are met.
- An example of For loop with all three particles, -
for(i=1;i<=10;i++) { printf("%d \n",i); }
- There are basic 3 parts of any For loop - Initialisation, Condition, Increment, and decrement.
Answer:
Semicolon
Step-by-step explanation:
A for loop consists of three parts:-
1. Initialization
2. Condition
3. Increment/Decrement.
Syntax:- for(initialize; condition; increment/decrement)
Three three statements are separated by a semicolon. Semicolon is a legitimate statement called null statement that means "do nothing". Since the for loop executes a single operation as it could be a block enclosed in { }, semicolon is treated as the body of the loop.
Semicolon acts as a terminator which indicates the compiler to break the flow and everything written after semicolon will be considered as a different statement.
When we write a semicolon at the end of a for loop, the for loop itself becomes a statement i.e. it becomes a empty loop and it has no body.
Example - for (i = 0; str[i] != '\0'; ++i);
#SPJ2