For Loop in c

Perhaps one reason why few programmers use while is that they are too busy using the for, which is probably the most popular looping instruction. The for allows us to specify three things about a loop in a single line: 

(a) Setting a loop counter to an initial value. 

(b) Testing the loop counter to determine whether its value has reached the number of repetitions desired. 

(c) Increasing the value of loop counter each time the program segment within the loop has been executed. 

for ( initialise counter ; test counter ; increment counter ) 

{

do this ; 

and this ; 

and this ; 

example:-

for ( i=0; i<5; i++) 

{

print("Hello\n");

Here the out put of this example will be 

Hello

Hello

Hello

Hello

Hello

Here i start with 0 and goes to 4 because 4 is less then 5 but when i =5 then the loop break, reason condition is false. 

Nesting of Loops:-

for(j=0;j<3;j++)

{

for ( i=0; i<2; i++) 

{

        print("Hello\t");

}

print("\n"); 

}

Output:-

Hello          Hello

Hello          Hello

Hello          Hello


You may also like

What is PHP?

PHP stands for PHP: Hypertext pre-processor, with that PHP standi...

What is ASP.NET?

ASP.NET, the next version of ASP, is a programming framework used...

What is Data Structure?

A data structure is a group of data elements grouped together und...

What is C#?

C# removes some of the complexities and pitfalls of languages suc...

What is Math?

Math is no Definition it has only Calculation.Closure Property of...

What is Oracle?

Based in Redwood, California, Oracle Corporation is the largest s...

Function in java

A function in Java language is a block of code that performs a sp...

Do-While Loop in java

The do-while loop looks like this:do{ this ; and this ; and this ...