Page 48 - MAIDA-23833025
P. 48
Modul Dasar Pemrograman
Contoh-7 /* ------------------- */
/* Program while01.cpp */
/* ------------------- */
#include <stdio.h>
#include <conio.h>
main( )
{
int bil=1;
clrscr( );
while(bil<=10)
{
printf(" %d ",bil);
++bil;
}
getch( );
}
Output yang akan dihasilkan, dari program contoh-9 diatas adalah:
Gambar 4. 6 Hasil Contoh 7
Contoh-8 /* ------------------- */
/* Program while02.cpp */
/* ------------------- */
#include <stdio.h>
#include <conio.h>
main( )
{
int bil=2;
clrscr( );
while(bil<=10)
{
printf(" %d ",bil);
bil+=2;
}
getch( );
}
Output yang akan dihasilkan, dari program contoh-10 diatas adalah :
45
47