For

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();
}

Posted in . Bookmark the permalink. RSS feed for this post.

Leave a Reply

Search

Support by Blogger ITN | Converted by LiteThemes.com