The idea of programming might sound like a frightening task, but don’t worry. We designed this blog so that you can get your feet wet without stepping into the deeper complexities of the programming.
This site is dedicated to all those people who want to learn the most basic but important Programming Language'C Programming'.
If done step wise C language is easy and fun to learn.
So lets get started.
Start reading from the First Post to understand C programming.You may read a desired topic from the labels.
One of the best methods to learn any programming language is to observe as much as programs you can , try editing them.
You can take a look at the various programs on this blog and feel free to ask if any doubts in with them.
Press Ctrl+D to add this page to your Favourites/Bookmarks for further reference.
Note:Your comments,queries and suggestions are welcome.Feel free to post them in the the comment boxes available after every post.

If you are interested in learning PHP, to create your own website or to spice up your existing website;here is the Best Tutorial available for PHP

Search C Programs,Compilers,Seminars ,Projects,etc.

Saturday, September 27, 2008

The While Loop

The While Loop

While programming we often need to do something a fixed number of times.
In such cases the While loop is used.
Lets study it with the help of an example below;

/* Calculation of simple interest for 3 sets of p, n and r */

main( )


int p, n, count ;

float r, si ;

count = 1 ;

while ( count <= 3 )


printf ( "\nEnter values of p, n and r " ) ;

scanf ( "%d %d %f", &p, &n, &r ) ;

si = p * n * r / 100 ;

printf ( "Simple interest = Rs. %f", si ) ;

count = count + 1 ;



The program above executes all statements after while three times.The logic of calculating simple interest is written in braces after the while word and is called as the body of the while loop.The brackets after the while contains the condition.All the statements within the loop are executed till the condition is true.

Another program which uses while loop,to print the average of the numbers input .The Program