Programming with C

⌘K
  1. Home
  2. Docs
  3. Programming with C
  4. Input/Output statements
  5. Looping statements

Looping statements

Iteration is a process of repeating the same set of statements again and again until the specified condition holds true

Three kinds of iteration statements,

  • for statement
  • while statement
  • do-while statement

General classification of Loops are,

  • Counter-controlled loops
  • Sentinel-controlled loops

Counter controlled loops,

  • It is a form of looping in which the number of iterations to be performed is known in advance
  • It is so named because they use a control variable, known as loop counter to keep track of a loop iterations
  • It starts with some initial value of the loop counter and terminates when the final value of the loop counter is reached.
  • Since the counter-controlled loops iterate a fixed number of times, which is known in advance they are also known as definite repetition loop

The ingredients of counter-controlled loops are,

  • Initialization of the loop counter
  • An expression (condition) determining whether the loop body should be executed or not
  • An expression that manipulates the value of the loop counter so that the condition specified becomes false and loop terminates

Views: 0

Articles

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments