Dalam membuat program dengan bahasa
C++ kita harus mengetahui terlebih dahulu struktur dalam C++. Yaitu :
File
Header berisi prototype (judul, nama dan sintak) sekumpilan fungsi
tertentu ( akan disimpan di file pustaka/file library dengan executable .LIB)
Inisial :
protoype dari fungsi-fungsi pustaka printf ( ) dan scanf ( ) terdapat di file
header stdio.h
Penulisan file header
#include
<stdio.h>
Atau
#include “stdio.h”
Inisial File Header
printf( ) <stdio.h>
getch( ) <conio.h>
cout( ) <iostream.h>
contoh struktur sederhana program C++
Contoh 1
Source code:
#include <stdio.h>
#include <conio.h>
main()
{
printf(" BIODATA
SISWA\n");
printf("=============================================\n");
printf("NISN =
98278847\n");
printf("Nama = M
RIZKI\n");
printf("Kelas = 6
SD\n");
printf("TTL = 30
Februari 2007\n");
printf("Alamat = Jl.
Masjid 1 Kesugihan\n");
printf("=============================================\n");
getch();
}
Berikut hasil outputnya
Contoh 2
Source code:
#include <stdio.h>
#include <conio.h>
main()
{
printf(" Pembelian Tiket Pesawat\n");
printf("============================================\n");
printf("No. Transaksi
= 0001\n");
printf("Nama Lengkap
= Dolby Romero\n");
printf("Kelas Penerbangan
= Pribadi\n");
printf("No. Kontak
= 0895422476033\n");
printf("Alamat Lengkap
= Jl. Masjid 1\n");
printf("Tanggal Pemberangkatan = 1 Oktober 2018\n");
printf("Harga
= Rp. 250.000,00\n");
printf("Jumlah Beli
= 2 Tiket\n");
printf("Total
= Rp. 500.000,00\n");
printf("============================================\n");
getch();
}
Berikut hasil outputnya




No comments:
Post a Comment