For Looop in C program

Asked By 20 points N/A Posted on -
qa-featured

What is For Loop, and how can I use it to produce a productive and simple program on C?

SHARE
Best Answer by Lesten Pasio
Answered By 5 points N/A #102879

For Looop in C program

qa-featured

C is the programming Language developed by Dennis Ritchie and now it is the basic for any programming language as major benefits are only with C language.

Loop is defined the execution revolves around until the condition get satisfied and for kloop is majorly used in many programs for smooth execution.

Syntax of the for loop itself defines us how the loop gets executed by condition as follows..

for(k=0;k<5;k++)–> k is an variable and here there are 3 major parts that is initialization is done for the value k to 0 and then the condition is tested if true then increment is done and when ever it is FALSE comes out of the loop.

Setting loop to initial value, testing the loop condition which is defined in the loop and finally increments if satisfied or else comes out from the loop if not satisfied.

Thank you.

Best Answer
Best Answer
Answered By 40 points N/A #102880

For Looop in C program

qa-featured

Hi Kenny ,

For loop is an interaction statement , in which we use it , when we know how  many times we want the loop to get iterated.

For is used for continuous repetitions.

For loop contains 4 parts : – 

1. Initialization Expression.

2. Test expression

3. Update expression.

4. The body of the loop.

Initialization expression is where the variable gets initialized and gets its first value

Test expression is where the initialized variable is tested against some other variable and if its true the loop is executed.

Update expression is where the initialized variable's value is changed .

Body of the loop contains the set of actions to be performed repeatedly when the test expression evaluates to true.

Syntax of for loop :- 

for(init expression ;test expression ; update expression )

{

Body of the loop 

}

Answered By 20 points N/A #102881

For Looop in C program

qa-featured

Than you for all your help regarding what for loop if. Now I know what it's for.

Thanks Hoting Gracia and Lesten Pasio. Thank you TechyV.

Related Questions