Example 1:
# include <iostream.h>
# include <conio.h>
main()
{
int loop,counter;
clrscr();
for(counter=0;counter<5;counter++)
{
for(loop=0;loop<counter;loop++)
{
cout <<counter;
}
cout <<"\n";
}
getch();
}
Example 2:
# include <iostream.h>
# include <conio.h>
main()
{
int bil,loop,counter;
clrscr();
cout <<"Masukkan sembarang bilangan ! : ";
cin >>bil;
for(counter=0;counter<=bil;counter++)
{
for(loop=1;loop<counter;loop++)
{
cout <<"*";
}
cout <<"\n";
}
for(counter=bil;counter>=0;counter--)
{
for(loop=2;loop<counter;loop++)
{
cout <<"*";
}
cout <<"\n";
}
getch();
}
Search
Categories
- Part I : Perkenalan (4)
- Part II : Operator (3)
- Part III : Percabangan (materi) (2)
- Part III : Percabangan (program) (4)
- Part IV : Perulangan (meteri) (3)
- Part IV : Perulangan (program) (3)
- Part V : Array (materi) (1)
- Part V : Array (program) (2)
- Penerapan (6)
- Pointer (2)
- Searching (pencarian) (3)
- Typedef (1)