Lec c3 - Now moves to Looping Iteration in C for statement...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Now moves to Looping Iteration in C for statement while statement do-while statement
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Basics of loops 1. Initialization of a condition variable. 2. Execution of the loop statements. 3. Test for a specified value of the condition variable. 4. Updating the condition variable. 1. C provides three constructs for loop operations 1. The for statement 2. The while statement 3. The do –while statement
Background image of page 2
for Statement Structure: for (init; test-condn; incr/decr) { loop_body; } Loop body can have a single statement or a group of statements. init test loop_body updation F T
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
While while (test) { loop_body; } test loop_body T F Loop body can contain block of statements. Executes loop body as long as test evaluates to TRUE (non-zero). Note: Test is evaluated before executing loop body.
Background image of page 4
For vs. While In general: For loop is preferred for counter -based loops. Explicit counter variable Easy to see how counter is modified each loop While loop is preferred for
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/14/2010 for the course CS SS ZG653 taught by Professor Shanta during the Spring '09 term at Birla Institute of Technology & Science.

Page1 / 14

Lec c3 - Now moves to Looping Iteration in C for statement...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online