Hai bro... ni contoh buat kamu yqang ingin belajar coding tentang struck... Monggo di simak
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <iomanip>
void main()
{
int a,jml;
struct {
char nama[25];
char alamat[80];
char tanggaldaftar[20];
char jeniskelamin[50];
int notlp;
}
member[50];
cout<<"\t\t\tPROGRAM DATA PELANGGAN \n\n\n ";
cout<<"Jumlah Pelangan Yang Akan Di Inputkan: "; cin>>jml;
cout<<"\n";
for (a=1;a<=jml;a++)
{
cout<<"Pelangan Ke- "<<a<<endl;
cout<<"Masukan Nama Member\t\t= "; cin>>member[a].nama;
cout<<"Masukan Alamat Member\t\t= "; cin>>member[a].alamat;
cout<<"Masukan Tanggal Daftar Member\t\t= "; cin>>member[a].tanggaldaftar;
cout<<"Masukan Jenis Kelamin Member\t\t\t= "; cin>>member[a].jeniskelamin;
cout<<"Masukan No.tlp Member\t\t= +628"; cin>>member[a].notlp;
cout<<endl;
}
cout<<endl<<endl;
cout<<"============================================================================"<<endl;
cout<<"|Pelangan| Nama | alamat | Tanggal Daftar | Jenis Kelamin | Nomor Telpon |"<<endl;
cout<<"============================================================================"<<endl;
for (a=1; a<=jml; a++)
{
cout<<" "<<setiosflags(ios::left)<<setw(8)<<a;
cout<<" "<<setiosflags(ios::left)<<setw(8)<<member[a].nama;
cout<<" "<<setiosflags(ios::left)<<setw(8)<<member[a].alamat;
cout<<" "<<setiosflags(ios::left)<<setw(8)<<member[a].tanggaldaftar;
cout<<" "<<setiosflags(ios::left)<<setw(8)<<member[a].jeniskelamin;
cout<<" "<<setiosflags (ios::right)<<setw(9);
cout<<" +628"<<setprecision(2)<<member[a].notlp
<<endl;
;
}
cout<<"============================================================================="<<endl;
getch() ;
}
Hasil Running Program
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <iomanip>
void main()
{
int a,jml;
struct {
char nama[25];
char alamat[80];
char tanggaldaftar[20];
char jeniskelamin[50];
int notlp;
}
member[50];
cout<<"\t\t\tPROGRAM DATA PELANGGAN \n\n\n ";
cout<<"Jumlah Pelangan Yang Akan Di Inputkan: "; cin>>jml;
cout<<"\n";
for (a=1;a<=jml;a++)
{
cout<<"Pelangan Ke- "<<a<<endl;
cout<<"Masukan Nama Member\t\t= "; cin>>member[a].nama;
cout<<"Masukan Alamat Member\t\t= "; cin>>member[a].alamat;
cout<<"Masukan Tanggal Daftar Member\t\t= "; cin>>member[a].tanggaldaftar;
cout<<"Masukan Jenis Kelamin Member\t\t\t= "; cin>>member[a].jeniskelamin;
cout<<"Masukan No.tlp Member\t\t= +628"; cin>>member[a].notlp;
cout<<endl;
}
cout<<endl<<endl;
cout<<"============================================================================"<<endl;
cout<<"|Pelangan| Nama | alamat | Tanggal Daftar | Jenis Kelamin | Nomor Telpon |"<<endl;
cout<<"============================================================================"<<endl;
for (a=1; a<=jml; a++)
{
cout<<" "<<setiosflags(ios::left)<<setw(8)<<a;
cout<<" "<<setiosflags(ios::left)<<setw(8)<<member[a].nama;
cout<<" "<<setiosflags(ios::left)<<setw(8)<<member[a].alamat;
cout<<" "<<setiosflags(ios::left)<<setw(8)<<member[a].tanggaldaftar;
cout<<" "<<setiosflags(ios::left)<<setw(8)<<member[a].jeniskelamin;
cout<<" "<<setiosflags (ios::right)<<setw(9);
cout<<" +628"<<setprecision(2)<<member[a].notlp
<<endl;
;
}
cout<<"============================================================================="<<endl;
getch() ;
}
Hasil Running Program
0 komentar
Posting Komentar