Contoh If dalam If di Broland C++
#include<iostream.h>
#include<conio.h>
main()
{
char kode,ukuran,merk[15];
long harga=0;
clrscr();
cout<<"Masukan kode Baju [1/2]:";cin>>kode;
cout<<"Masukan Ukuran Baju:";cin>>ukuran;
if (kode=='1')
{
strcpy(merk,"Supreme");
if(ukuran=='s')
harga=20000;
else (ukuran=='m');
harga=50000;
}
if (kode=='2')
{
strcpy (merk,"Adidas");
if(ukuran=='s')
harga=10000;
else (ukuran=='m');
harga=50000;
}
cout<<"----------------------------------------"<<endl;
cout<<"Maka merek baju :"<<merk<<endl;
cout<<"Ukuran baju :"<<ukuran<<endl;
cout<<"harga bahy :Rp. "<<harga<<endl;
getch();
}
0 Komentar