Untuk materi dasar for, dapat dilihat di sini!
Example 1:
# include <iostream.h>
# include <conio.h>
main()
{
int number;
clrscr();
for(number=1;number<5;number=number+1)
{
cout <<number;
cout <<"\n";
}
getch();
}
Example 2 :
# include <iostream.h>
# include <conio.h>
main()
{
clrscr();
for(int number=1;number<5;number=number+1) //Declaration variable type, example (int) will do in property for
{
cout <<number;
cout <<"\n";
}
getch();
}
Example 3:
# include <iostream.h>
# include <conio.h>
main()
{
int number;
clrscr();
number=1;
for( ;number<=5; ) //Initial Variable in property for, moved before intruction for. fix Condition write in property for. And Interval put on under instruction for
{
cout <<number;
cout <<"\n";
bil++; //interval can brief writing from number=number+1 to be number++, and number=number-1 to be number--
}
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)