Home > Coretan Pribadi Gw, Tip And Trick, TIPS & TRICK, Windows > Fungsi Array C++ Bagian 1

Fungsi Array C++ Bagian 1

Contoh array :

# include <stdio.h>
# include <conio.h>
# include <iostream.h>
# include <iomanip.h>
main()
{
char np[15],kd[5][25],nb[20][25],lagi; //kd[5][25]–>[5] banyak digit, [25]–>arraynya
int i,j;
float hrg[25],jml[25],tot[25];
awal:
clrscr();
textcolor(13);cprintf(” PT. UNTUNG RUGI”);
cout<<endl;
cout<<“JL. Kalibata Timur No.37 telp (021) 7901074″<<endl;
cout<<“———————————————-“<<endl;
textcolor(13);cprintf(“Masukan nama pembeli :”);cin>>np; //textnya berwarna ping..(harus pk cprintf)
cout<<“masukan Jumlah Data :”;cin>>j;
for(i=1;i<=j;i++)
{
cout<<“Data Ke – “<<i<<endl;
cout<<“Masukan Kode barang :”;cin>>kd[i];
cout<<“Masukan Nama Barang :”;cin>>nb[i];
cout<<“Masukan harga Barang :”;cin>>hrg[i];
cout<<“Masukan Jumlah Beli :”;cin>>jml[i];
tot[i]=hrg[i]*jml[i];
cout<<endl;
}
clrscr();
cout<<endl;

cout<<” PT. UNTUNG RUGI”<<endl;
cout<<” JL. Kalibata Timur No.37 telp (021) 7901074″<<endl;
cout<<endl;
cout<<“Nama Pembeli : “<<np<<endl;
cout<<“==========================================================”<<endl;
cout<<“No. Kode Nama Harga Jumlah Total “<<endl;
cout<<” Barang Barang Barang Beli Bayar”<<endl;
cout<<“==========================================================”<<endl;
for(i=1;i<=j;i++)
{
cout<<setiosflags(ios::left)<<setw(5)<<i; //jarak antar no dan kode 5 digit
cout<<setiosflags(ios::left)<<setw(8)<<kd[i];
cout<<setiosflags(ios::left)<<setw(10)<<nb[i];
cout<<setiosflags(ios::left)<<setw(11)<<hrg[i];
cout<<setiosflags(ios::left)<<setw(9)<<jml[i];
cout<<setiosflags(ios::left)<<setw(8)<<tot[i]<<endl;
}
cout<<“===========================================================”<<endl;
cout<<“Mau input data lagi [Y/T] =”;cin>>lagi;
if (lagi==’Y’|| lagi==’y’)
goto awal;
else
goto akhir;
akhir:
clrscr();cout<<endl;cout<<“TERIMA KASIH ATAS KEDATANGANNYA”;
getch();
}

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: