Saturday, March 27, 2010

For, While , & Do...While



CONTOHFOR:

#include
#include
#include
voidmain ()
{
int a;
for(a=1;a<=10;++a)
cout<
getch();
}





Project1:

#include
#include
#include
voidmain ()
{
int a;
for(a=10;a>=1;--a)
cout<
cout<<"\n";
getch();
}





PROJECT2:

#include
#include
#include
voidmain ()
{
int a;
for(a=1;a<=10;a=a+2)
cout<
cout<<"\n";
getch();
}





While:

#include
#include
#include
voidmain()
{
int bil=1;
while(bil <=10)
{
cout<<<"";
++bil;
}
cout<<"\n";
getch();
}




Whilegenap:

#include
#include
#include
voidmain()
{
int bil=2;
while(bil <=10)
{
cout<<<"";
bil=bil+2;
}
cout<<"\n";
getch();
}




DOWHILE:

#include
#include
#include
voidmain()
{
int bil=2;
do
{
cout<< bil<<"";
bil+2;
}
while(bil<=0);
getch();
}

No comments:

Post a Comment