..

FreePrograms


C programming Tutorial 

Free C Programs, C Programs Download


Embedded C lang & 8051(Embedded Products)


  CONTACT US   ABOUT US   PRIVACY  DISCLAIMER

FREE C PROGRAMS 

 C Tutorial for beginners
What is C C vs C++ vs Java Program Structure Data Types in C Basic Rules of C & C++
Functions in C If, Else Conditions Loops in C Switch Case Arrays
Pointers Structures in C Strings in C Command Line Arguments Type Casting
Linked Lists Recursion Binary Trees Inheritance Multiple Inheritance
Templates File I/O Object Oriented Programming  Data Structures in C C interview Questions

/*Loops-While, Do While, For Loop C++ Program C++/CPP Tutorial.*/


 

While loop

Program which writes freecprograms five(5) times.

#include<iostream.h>

int main()
{
int i=0;
while(i<5)
{
i++;
cout<<"freecprograms"<<endl;
}
}

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Do While loop

It is very similar to the while loop shown above. The only difference being, in a 'while' loop, the condition is checked beforehand, but in a 'do while' loop, the condition is checked after one execution of the loop as we explained you in our C basic tutorial.

lets write the above program using do while loop.

#include <iostream.h>
int main()
{
int i=0;
do
{
i++;
cout<<"freecprograms"<<endl;
}

while(i<5);
}

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


For Loop

Lets print the numbers 1 to 5, using a for loop.

#include<iostream.h>

int main()

{

for(int k=1;k<=5;k++)

cout<<k<<endl;

}

COPYRIGHT 2009 ALL RIGHTS RESERVED FREECPROGRAMS.COM