Ad Code

Responsive Advertisement

for loop of c language.


3)For loop :
 in for loop it diffrent from other loop but same as a while loo.

All the rule are write in one line. 

Syntex : for(assignning;condition;increment/decrement)
 {
          // program(task);
 }


Example :
#include<stdio. h>
Void main()
{
      int a;
    for(a=1; a<3; a++)
   {
          printf(" hello ") ;
   }
}
out put : hello
                hello



In the fop loop there have inner loop. Means loop inside a loop.

SYSTEX : for(assignning;condition;increment/decrement)
{
for(assignning;condition;increment/decrement)
{
// program(task);
}
}

example :
#include<stdio.h>
void main()
{
int a,b;

for(a=1; a<2; a++)
{
for(b=1; b<3; b++)
{
printf(“hello\n”);
}
}
}
OUT PUT: hello
          hello
     
first we understood the inner loop. When the first loop fisrt loop is execute one time than the inner loop execute it end time. Here for(a=1; a<2; a++) and inner loop for(b=1;b<3; b++)

when the first loop execute one time than the inner loop execute two time





❮ Previous                                                      Next ❯

Post a Comment

0 Comments