22. program penjualan barang
#include <stdio.h>
#include <conio.h>
#include <windows.h>
main()
{
int x,n,jumlah[100];
float harga[100],total[100],ts;
char nama[100][100],ulang;
ulang='y';
while(ulang=='y'||ulang=='Y')
{
system("CLS");
printf("jumlah data yang di inputkan = ");scanf("%d",&n);
for(x=1;x<=n;x++)
{
printf("\n\ndata ke %d",x);
printf("\nmasukan nama barang = ");fflush(stdin);gets(nama[x]);
printf("masukan jumlah barang = ");scanf("%d",&jumlah[x]);
printf("masukan harga barang = ");scanf("%f",&harga[x]);
}
for(x=1;x<=n;x++)
{
printf("\n\ndata ke %d",x);
printf("\nnama barang = %s",nama[x]);
printf("\njumlah barang = %d",jumlah[x]);
printf("\nharga barang = %0.f",harga[x]);
printf("\n------------------------------");
total[x]=jumlah[x]*harga[x];
printf("\ntotal = %0.f",total[x]);
ts=ts+total[x];
}
printf("\n=============================");
printf("\ntotal seluruh = %0.f",ts);
printf("\n=============================");
printf("\njika anda ingin mengulang tekan [y] = ");scanf("%s",&ulang);
}
getch();
}
#include <stdio.h>
#include <conio.h>
#include <windows.h>
main()
{
int x,n,jumlah[100];
float harga[100],total[100],ts;
char nama[100][100],ulang;
ulang='y';
while(ulang=='y'||ulang=='Y')
{
system("CLS");
printf("jumlah data yang di inputkan = ");scanf("%d",&n);
for(x=1;x<=n;x++)
{
printf("\n\ndata ke %d",x);
printf("\nmasukan nama barang = ");fflush(stdin);gets(nama[x]);
printf("masukan jumlah barang = ");scanf("%d",&jumlah[x]);
printf("masukan harga barang = ");scanf("%f",&harga[x]);
}
for(x=1;x<=n;x++)
{
printf("\n\ndata ke %d",x);
printf("\nnama barang = %s",nama[x]);
printf("\njumlah barang = %d",jumlah[x]);
printf("\nharga barang = %0.f",harga[x]);
printf("\n------------------------------");
total[x]=jumlah[x]*harga[x];
printf("\ntotal = %0.f",total[x]);
ts=ts+total[x];
}
printf("\n=============================");
printf("\ntotal seluruh = %0.f",ts);
printf("\n=============================");
printf("\njika anda ingin mengulang tekan [y] = ");scanf("%s",&ulang);
}
getch();
}
Komentar
Posting Komentar