Sunday, December 18, 2011

Fungsi garis dan struct

#include<conio.h>
#include<stdio.h>
#include<iostream.h>
garis()
{
cout<<" ======================\n";
}


main()
{
struct
   {
   char nama[10];
   int harga, jumlah, bayar;
   }client;


garis();
cout<<"    TOKO IMAM    \n";
garis();


cout<<"Masukkan nama pelanggan = ";cin>>client.nama;
cout<<"Masukkan harga          = ";cin>>client.harga;
cout<<"Masukkan jumlah beli    = ";cin>>client.jumlah;
client.bayar=client.harga*client.jumlah;
garis();
cout<<endl;
garis();
cout<<"    TOKO IMAM    \n";
garis();
cout<<"NAMA   = "<<client.nama<<endl;
cout<<"HARGA  = "<<client.harga<<endl;
cout<<"JUMLAH = "<<client.jumlah<<endl;
garis();
cout<<"BAYAR = "<<client.bayar<<endl;
garis();


getch();
}


dari listing program diatan jadi dah outputnya gini:

Comments
0 Comments

0 comments:

Post a Comment