Pages

Hello there!

Powered by Blogger.

Monday, January 7, 2013

WHILE LOOP IN C


WHILE LOOP IN C WITH EXAMPLE


While loop is simplest loop in c

Syntax:- 

while(condition)
{
Body of the loop
}
Statement;

Note:-

# If body of loop is only one statement than braces ({}) are not needed.
# Body of the loop may have one or more statement.

Execution:-

In while loop 1st condition will check if condition is true than body of the loop will executed. After body of the loop is execute, the condition is again tested if condition is true than again body of loop is executed, this process is repeated until condition is true. When condition is false than statement next to while loop is executed.

Example:-

Program to count N numbers

Program to display even number up to 20



0 comments:

Post a Comment