#include <iostream.h>
#include <conio.h>
main()
{
clrscr;
int n,p,o;
o=1;
p=1;
cout<< "input n: ";
cin>> n;
while (o<=n)
{
p=1;
while (p<=o)
{
cout<<"*";
p++;
}
cout<<endl;
o++;
}
n--;
while (n>=1)
{
p=n;
while (p>=1)
{
cout<<"*";
p--;
}
cout<<endl;
n--;
}
getch();
return 0;
}
Selasa, 22 Maret 2011
Perulangan While Pada C++ 7
#include <iostream.h>
#include <conio.h>
main()
{
clrscr;
int n,o,p;
o=1;
cout<< "input n: ";
cin>> n;
while (o<=n)
{
p=1;
while (p<=o)
{
cout<<"*";
p++;
}
cout<<endl;
o++;
}
getch();
return 0;
}
#include <conio.h>
main()
{
clrscr;
int n,o,p;
o=1;
cout<< "input n: ";
cin>> n;
while (o<=n)
{
p=1;
while (p<=o)
{
cout<<"*";
p++;
}
cout<<endl;
o++;
}
getch();
return 0;
}
Perulangan While Pada C++ 6
#include <iostream.h>
#include <conio.h>
main()
{
clrscr;
int n,o,p;
o=1;
cout<< "input n: ";
cin>> n;
while (o<=n)
{
p=1;
while (p<=o)
{
cout<<p;
p++;
}
cout<<endl;
o++;
}
getch();
return 0;
}
#include <conio.h>
main()
{
clrscr;
int n,o,p;
o=1;
cout<< "input n: ";
cin>> n;
while (o<=n)
{
p=1;
while (p<=o)
{
cout<<p;
p++;
}
cout<<endl;
o++;
}
getch();
return 0;
}
Perulangan While Pada C++ 5
#include <iostream.h>
#include <conio.h>
main()
{
clrscr;
int n;
cout<< "input n: ";
cin>> n;
while (n<9)
{
cout<<n<<",";
n++;
}
cout<<"fire"<<endl;
getch();
return 0;
}
#include <conio.h>
main()
{
clrscr;
int n;
cout<< "input n: ";
cin>> n;
while (n<9)
{
cout<<n<<",";
n++;
}
cout<<"fire"<<endl;
getch();
return 0;
}
Perulangan While Pada C++ 4
#include <iostream.h>
#include <conio.h>
main()
{
clrscr;
int n;
cout<< "input n: ";
cin>> n;
while (n>0)
{
cout<<n<<",";
--n;
}
cout<<"fire"<<endl;
getch();
return 0;
}
#include <conio.h>
main()
{
clrscr;
int n;
cout<< "input n: ";
cin>> n;
while (n>0)
{
cout<<n<<",";
--n;
}
cout<<"fire"<<endl;
getch();
return 0;
}
Perulangan While Pada C++ 3
#include <iostream.h>
#include <conio.h>
main()
{
clrscr;
int n,i;
i=1;
cout<< "input n: ";
cin>> n;
while (i<n)
{
cout<<i<<",";
i+=2;
}
cout<<"fire"<<endl;
getch();
return 0;
}
#include <conio.h>
main()
{
clrscr;
int n,i;
i=1;
cout<< "input n: ";
cin>> n;
while (i<n)
{
cout<<i<<",";
i+=2;
}
cout<<"fire"<<endl;
getch();
return 0;
}
Perulangan While Pada C++ 2
#include <iostream.h>
#include <conio.h>
int main()
{
clrscr;
int n,i;
i=0;
cout<< "input n: ";
cin>> n;
while (i<n)
{
i+=2;
cout<<i<<",";
}
cout<<"fire"<<endl;
getch();
return 0;
}
#include <conio.h>
int main()
{
clrscr;
int n,i;
i=0;
cout<< "input n: ";
cin>> n;
while (i<n)
{
i+=2;
cout<<i<<",";
}
cout<<"fire"<<endl;
getch();
return 0;
}
Langganan:
Postingan (Atom)