D4n9k3l's Blog
Just another WordPress.com weblog

Array

Listing Program Array :

#include<stdio.h>
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
main()
{
int i,n;
char kode[4][5],nama[4][20],tujuan[4][30],kelas[4][10],lg;
long int harga[4],jumlah[4],total[4];
cruise:
clrscr();
cout<<“STASIUN KERETA API\n\n”;
cout<<“Masukan Banyaknya Data : “;cin>>n;
for (i=1;i<=n;i++)
{
cout<<“Data Ke      : “<<i<<endl;
cout<<“Kode Kereta  : “;cin>>kode[i];
cout<<“Nama Kereta  : “;gets(nama[i]);
cout<<“Kota Tujuan  : “;gets(tujuan[i]);
cout<<“Kelas Kereta : “;gets(kelas[i]);
cout<<“Harga Tiket  : “;cin>>harga[i];
cout<<“Jumlah Beli  : “;cin>>jumlah[i];
clrscr();
total[i]=harga[i]*jumlah[i];
}
cout<<“\t\t\t  STASIUN KERETA API”<<endl;
cout<<“\t\t\t\tGAMBIR”<<endl;
cout<<“================================================================================”<<endl;
cout<<“No | Kd Kereta | Nm Kereta       | Tujuan | Kelas     | Harga | Jumlah | Total”<<endl;
cout<<“================================================================================”<<endl;
for (i=1;i<=n;i++)
{
cout<<setiosflags(ios::left)<<setw(5)<<i;
cout<<setiosflags(ios::left)<<setw(12)<<kode[i];
cout<<setiosflags(ios::left)<<setw(18)<<nama[i];
cout<<setiosflags(ios::left)<<setw(9)<<tujuan[i];
cout<<setiosflags(ios::left)<<setw(12)<<kelas[i];
cout<<setiosflags(ios::left)<<setw(8)<<harga[i];
cout<<setiosflags(ios::left)<<setw(9)<<jumlah[i];
cout<<setiosflags(ios::left)<<setw(10)<<total[i];
cout<<endl;
}
cout<<“================================================================================”<<endl;
cout<<” ingin input data [Y/T]  : “;cin>>lg;
if(lg==’Y’||lg==’y’)
goto cruise;
getch();
}

Belum Ada Tanggapan to “Array”

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: