Skip to main content

Understanding For-loop in C Language

FOR LOOP.

It allowed specifying three things about a loop is a single line:

  Ø  Setting a loop counter to an initial value.

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

  Ø  Increasing the value of loop counter each time the program segment has been executed.


General form of FOR LOOP statement:

It can be seen that three stapes are required for the loop construct have now been incorporated in the FOR LOOP statement:

  Ø  Initialization

  Ø  Testing

  Ø  Incrementation


Execution of FOR LOOP statement:

  Ø  When for statement is executed for the first time, the value of count set to an initial value 1.

  Ø  Now the condition “count<=3” tested. Since count is 1, the condition is satisfied and body of the loop is executed for the first time.

  Ø  Upon reaching the closing brace of for, a computer sends the control back to the for the statement, where the value of count gets incremented by 1.

  Ø  Again the test is performed to check whether the new value of count exceeds 3.

  Ø  The body of the FOR LOOP statement continuous to get executed till count doesn’t exceed the final value 3.

  Ø    When count reach the value 4, the control exits from the loop and is transfer to the statement immediately after the body for FOR LOOP.

 

Comments

Popular posts from this blog

How To Know Best Tools For Social Media Marketing Part 2

  Best Tools For Social Media Marketing Part 2 Today we will tell you about social media marketing tools Part 2. in this article remaining 6 tools, which are helping in a social media campaign. Unsplash: - It is very important to have amazing images while having high-quality textual content. Unsplash provides a database of high-resolution, great images that you can use with your posts, the fact that a good image has its own unique significance cannot be denied. Each image is properly tagged so that you can find the most appropriate image for your post. Marin: - If your agency runs a social media advertising campaign (campaign), then this social media management tool will be useful for you. Marin offers a range of features that promise to increase your ROI by up to 30% compared to native equipment. One of its cool features is called auto-split which helps your audience in the micro-segment. Nimble: - As your customer list grows, a powerful CRM is needed to automate data manag...