0% found this document useful (0 votes)
2K views

CONTOH Soal Pointer C++

This C++ program allows a user to input purchase codes and quantities. It then outputs a receipt listing the item codes, names, and prices. The user is prompted to enter a number of purchases and for each one, a code (A/a for Honda at 500k or B/b for Yamaha at 450k). The codes and associated names and prices are stored in arrays. Finally, a formatted output is printed listing the item numbers, codes, names, and prices.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

CONTOH Soal Pointer C++

This C++ program allows a user to input purchase codes and quantities. It then outputs a receipt listing the item codes, names, and prices. The user is prompted to enter a number of purchases and for each one, a code (A/a for Honda at 500k or B/b for Yamaha at 450k). The codes and associated names and prices are stored in arrays. Finally, a formatted output is printed listing the item numbers, codes, names, and prices.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<conio.

h>
#include<iostream.h>
#include<stdio.h>
#include<iomanip.h>
main()
{
int a,jb;
char kd[50],*sk[50];
long h[50];
clrscr();
cout<<"masukan jumlah beli : ";cin>>jb;
for(a=1;a<=jb;a++)
{
cout<<"masukan kode : ";cin>>kd[a];
if(kd[a]=='a'||kd[a]=='A')
{
sk[a]="honda";
h[a]=500000;
}
else if(kd[a]=='b'||kd[a]=='B')
{
sk[a]="yamaha";
h[a]=450000;
}
else
cout<<"salah kode...."<<endl;
}
cout<<"\n\t\tTekan enter.."<<endl;
getche();
clrscr();
cout<<"-------------------------------------------"<<endl;
cout<<"No. Suku cadang Harga "<<endl;
cout<<"-------------------------------------------"<<endl;
for(a=1;a<=jb;a++)
{
cout<<setiosflags(ios::left)<<setw(4)<<a;
cout<<setiosflags(ios::left)<<setw(6)<<kd[a];
cout<<setiosflags(ios::left)<<setw(13)<<sk[a];
cout<<setiosflags(ios::left)<<setw(5)<<h[a]<<endl;
}
cout<<"-------------------------------------------"<<endl;
getch();
}

You might also like