seteatment if-else-else if :
#include
#include
using namespace std;
int main(int argc, char *argv[])
{ int x;cout<<"x : ";cin>>x;
if(x==0,x<=5)
cout<<" data 0-5 berhasil di cetak "<
else if(x==6,x<=10)
cout<<" data 6-10 berhasil di cetak "<
else if(x==11,x<=15)
cout<<" data 11-15 berhasil dicetak "<
else if(x==16,x<=20)
cout<<" data 16-20 berhasil dicetak "<
else
cout<<"gagal di cetak"<
system("PAUSE");
return 0;
}
switch case - nama bulan :
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
int x;cout<<" Masukan anka X untuk mencri nama bulan : "<<<"X = ";cin>>x;
switch (x){
case 1:
cout<<"January "<
break;
case 2:
cout<<"Februari"<
break;
case 3:
cout<<"Maret "<
break;
case 4:
cout<<"April "<
break;
case 5:
cout<<"Mei "<
break;
case 6:
cout<<"Juni "<
break;
case 7:
cout<<"July "<
break;
case 8:
cout<<"Agustus "<
break;
case 9:
cout<<"September "<
break;
case 10:
cout<<"Oktober"<
break;
case 11:
cout<<"November "<
break;
case 12:
cout<<"Desember"<
break;
default:
{
cout<<"Nama Bulan tidak tersedia "<
break;
}
}
system("PAUSE");
return EXIT_SUCCESS;
}
Tidak ada komentar:
Posting Komentar