Coding Menampilkan Harga Barang
main()
{
struct nama_barang
{
char kode [20];
char barang [20];
float jumlah;
float harga;
};
struct nama_barang pilihan[20] =
{
" M01"," Monitor ",2,1100000,
" M02"," Motherboard ",4,1000000,
" M03"," DDR3 ",3,420000,
" M04"," Processor ",2,1500000,
" M05"," Harddisk ",6,550000,
};
int a,b=5;
float jml=0;
printf(" PROGRAM MENAMPIILKAN JUMLAH BARANG "); printf("\n");
printf ("____________________________________________________\n\n");
printf (" Kode Barang Jumlah Harga Total\n");
printf ("____________________________________________________\n\n");
for (a=0;a {
printf (" %s", pilihan[a].kode);
printf (" %s", pilihan[a].barang);
printf (" %.f", pilihan[a].jumlah);
printf (" %.f", pilihan[a].harga);
printf (" %.f", pilihan[a].jumlah*pilihan[a].harga);
printf ("\n\n");
jml+=pilihan[a].jumlah*pilihan[a].harga;
}
printf ("____________________________________________________\n\n");
printf (" Jumlah Total = %.f \n",jml);
printf ("____________________________________________________\n\n");
}
Post a Comment
1. Jangan lupa tinggalkan Likenya ya
2. Berkomentarlah dengan baik dan sopan