Loops

The Looping statements are used for execution of a (block of) statement(s) for multiple no. of times , according to the conditions specified in the loops .




various statements used for executing loops in C are :

StatementsWhat They Contain..Minimum Executions
ForMain statement contains initialization value , condition check & value modification . 0
WhileMain statement contains condition check , initialization before and value check anywhere inside the looping block .0
Do-whileDo part contains the executable block , while part contains the condition .1



The For Loop

The For Looping statement is used for multiple executions. The different parts are :
1. The Initialization
2. Condition Check
3. Increment/Decrement Value

It can be also used in the Nested form , meaning loops inside loops.



Syntax for 'For Loop'


for(variable initialization ; condition check ; value modify ) 



Example:    for ( i=0 ; i<7 ; i++ )




C Example


#include<stdio.h>

int main() {

	int i;

	for (i=1;i<6;i++) {

		printf("%d\n",i);

	}

	printf("loop over");

	return 0;

}


Quantitative Aptitude
Reasoning
Programming
Interview