BLOGGER TEMPLATES AND TWITTER BACKGROUNDS »

Saturday, March 26, 2011

LOOP & WHILE

LOOP
#include <iostream.h>
main()
{
//declare variable
//get input
cout <<"enter an integer = ";
cin >> x;
//loop for
for (y=0;y<x;y++)
{
cout <<"     "<<x;
}

WHILE
#include <iostream.h>
main()
int x.y;
cout<<"enter an integer =";
cin>>x;
//while
y=1;
while (y<x)
{
cout <<"     "<<x;
y++;
}
}

0 comments: