1. Perulangan While
2. Perulangan Do..While
3. Perulangan For
1. Perulangan While
Do
Bentuk Umum : {
Statement
...
}
While (kondisi)
Contoh program Do…While
#include<stdio.h>
#include<conio.h>
main()
{
int i;
clrscr();
i=1;
do
{
printf("%d\n",i);
i++;
}
while(i<=5);
}
3. Perulangan for
Struktur perulangan for biasa digunakan unutk mengulang suatu proses
yang telah diketahui jumlah perulangannya.
Bentuk Umum :
main()
{
int i;
for (i=10;i>0;i--)
{
printf("\n Bahasa C%5i",i) ;
}
getch();
}
Contoh For bersarang
#include<stdio.h>
#include<conio.h>
main()
{
int i,n,j;
for (i=1; i<=3; i++)
{
for (j = 1; j <=i ; j++)
{
printf(“*”);
}
Printf(“\n”);
}
Printf("program selesai");
}