Page 43 - MAIDA-23833025
P. 43
Modul Dasar Pemrograman
for(a = 1; a <= 10; ++a)
cout>>a;
getch( );
}
Output yang akan dihasilkan, dari program contoh-1 diatas adalah :
Gambar 4. 1 Hasil Contoh 1
Contoh-2 /* ---------------------------- */
/* Program for - bilangan turun */
/* ---------------------------- */
# include <stdio.h>
# include <conio.h>
#include<iostream.h>
main( )
{
int a;
clrscr( );
for(a = 10; a >= 1; --a)
cout<<a;
getch( );
}
Output yang akan dihasilkan, dari program contoh-2 diatas adalah :
Gambar 4. 2 Hasil Contoh 2
Contoh-3 /* ----------------------------- */
/* Program for - bilangan ganjil */
/* ----------------------------- */
#include <stdio.h>
#include <conio.h>
#include<iostream.h>
main( )
40
42