google.com, pub-8786015629279405, DIRECT, f08c47fec0942fa0 For Loop in C

For Loop in C

1
As we discuss about the Looping in the Previous section, Looping is a process which is used to execute a set of statements repetitively when a certain condition true.

C provides three ways to execute the loops. While all of the ways offer similar basic functionality, but differ in syntax and condition.



For Loop :


For loop, the loop structure provides a concise way of writing. Unlike a while loop, a statement consumes the initialization, condition, and increment / decrement in one line, thus creating a shorter, easy to debug looping structure.


Syntax:

for(initialization ; Test Condition ; Increment/ Decrement)
{
Statements or Body of Loop
}



1.Initialization: We initialize the variable in use here. It marks the beginning of a for loop. It is possible to use an already declared variable, or to declare a variable, local to loop only.

2. Test Condition: It is used to test a loop's exit condition. They have to return a boolean value. It is also an Entry Control Loop, since the condition is checked before the loop statements are executed.

3. Execution of statements: Once the condition is evaluated to true, the statements are executed in the body of the loop.

4.Increment / Decrement: Used for next iteration to change the variable.

5. Loop termination: When the state is incorrect the loop stops signaling the end of its cycle of life.

Flow Chart of For Loop:

For Loop in Java



Post a Comment

1 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Thank you for your interest 😊

We will back shortly after reviewing...

Thank you for your interest 😊

We will back shortly after reviewing...

Post a Comment

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top