একই জিনিস বারংবার ( looping ) করতে হলে কি করতে হবে ?

Submitted by administrator on Mon, 01/02/2012 - 15:25

CLASS 7 - Doing the Same Thing Over and Over

In the previous lessons, you've learned the basics of the C program, several important C functions, standard I/O, and some useful operators. In this lesson you'll learn a very important feature of the C language—looping. Looping, also called iteration, is used in programming to perform the same set of statements over and over until certain specified conditions are met.

Three statements in C are designed for looping:

  •     The for statement
  •     The while statement
  •     The do-while statement



Summary
In this lesson you've learned the following:

  •     Looping can be used to perform the same set of statements over and over until specified conditions are met.
  •     Looping makes your program concise.
  •     There are three statements, for, while, and do-while, that are used for looping
  •     in C.
  •     There are three expression fields in the for statement. The second field contains the expression used as the specified condition(s).
  •     The for statement does not end with a semicolon.
  •     The empty for( ; ; ) statement can be used to form an infinite loop.
  •     Multiple expressions, separated by commas, can be used in the for statement.
  •     There is only one expression field in the while statement, and the expression is used as the specified condition.
  •     The while statement does not end with a semicolon.
  •     The while (1) statement can create an infinite loop.
  •     The do-while statement places its expression at the bottom of the loop.
  •     The do-while statement does end with a semicolon.
  •     The inner loop must finish first before the outer loop resumes its iteration in nested loops.


In the next lesson you'll learn about more operators used in the C language.
 

Related Items

The #define and #undef Directives

The #define and #undef Directives

The #define directive is the most common preprocessor directive, which tells the preprocessor to replace every occurrence of a particular character string (that is, a macro name) with a specified value (that is, a macro body).

The C Preprocessor Versus the Compiler

The C Preprocessor Versus the Compiler

One important thing you need to remember is that the C preprocessor is not part of the C compiler.

What Is the C Preprocessor?

If there is a constant appearing in several places in your program, it's a good idea to associate a symbolic name to the constant, and then use the symbolic name to replace the constant throughout the program. There are two advantages to doing so. First, your program will be more readable.

Exercises : Answer the following Question

To help solidify your understanding of this hour's lesson, you are encouraged to answer the quiz questions and finish the exercises provided in the Workshop before you move to the next lesson.

Question and Answer

    Q Why is random access to a disk file necessary?