BLOG INI MEMBERI SEDIKIT TAMBAHAN INFORMASI UNTUK MAHASISWA KHUSUS NYA MAHASISWA SISTEM INFORMASI
SELAMAT DATANG KE BLOG SAYA
MOGA BERMANFAAT UNTUK ANDA
MOGA BERMANFAAT UNTUK ANDA
Rabu, 13 April 2011
NESTED FOR
#include<iostream.h>
main()
{
int a,b;
clrscr();
cout<<" program nested for \n ";
for(a=1; a<=5; a+=5)
{
printf("\n");
for(b=a; b<=1; b+=1)
cout<<a<<" ";
}
for(a=1; a<=4; a+=4)
{
printf("\n");
for(b=a; b<=2; b+=1)
cout<<a<<" ";
}
for(a=1; a<=3; a+=3)
{
printf("\n");
for(b=a; b<=3; b+=1)
cout<<a<<" ";
}
for(a=1; a<=4; a+=4)
{
printf("\n");
for(b=a; b<=4; b+=1)
cout<<a<<" ";
}
for(a=1; a<=5; a+=5)
{
printf("\n");
for(b=a; b<=5; b+=1)
cout<<a<<" ";
}
getch();
}
Kamis, 07 April 2011
PROGRAM C++ switch case
//jamilah salwa lala//
#include<conio.h>
#include<iostream.h>
#include<stdio.h>
main()
{
char kode1;
char kode2;
clrscr();
cout<<" INPUTKAN KODE KELAS ANDA [E/B/X]: ";
cin>>kode1;
switch(kode1)
{
case 'E':
cout<<" EKONOMI";
cout<<" \n INPUTKAN KODE TUJUAN ANDA [1/2]: ";
cin>>kode2;
switch(kode2)
{
case '1':
cout<<" \nBANGKOK";
cout<<"\nHARGA TIKET Rp$35";
break;
case '2':
cout<<" \nHONGKONG";
cout<<"\nHARGA TIKET Rp$45";
break;}getch();
break;
case 'B':
cout<<" EKONOMI";
cout<<" \n INPUTKAN KODE TUJUAN ANDA [1/2]: ";
cin>>kode2;
switch(kode2)
{
case '1':
cout<<" \nBANGKOK";
cout<<"\nHARGA TIKET Rp$45";
break;
case '2':
cout<<" \nHONGKONG";
cout<<"\nHARGA TIKET Rp$55";
break;}getch();
break;
case 'X':
cout<<" EKONOMI";
cout<<" \n INPUTKAN KODE TUJUAN ANDA [1/2]: ";
cin>>kode2;
switch(kode2)
{
case '1':
cout<<" \nBANGKOK";
cout<<"\nHARGA TIKET Rp$55";
break;
case '2':
cout<<"\n HONGKONG";
cout<<"\nHARGA TIKET Rp$65";
break;}getch();
break;
} getch();
}
#include<conio.h>
#include<iostream.h>
#include<stdio.h>
main()
{
char kode1;
char kode2;
clrscr();
cout<<" INPUTKAN KODE KELAS ANDA [E/B/X]: ";
cin>>kode1;
switch(kode1)
{
case 'E':
cout<<" EKONOMI";
cout<<" \n INPUTKAN KODE TUJUAN ANDA [1/2]: ";
cin>>kode2;
switch(kode2)
{
case '1':
cout<<" \nBANGKOK";
cout<<"\nHARGA TIKET Rp$35";
break;
case '2':
cout<<" \nHONGKONG";
cout<<"\nHARGA TIKET Rp$45";
break;}getch();
break;
case 'B':
cout<<" EKONOMI";
cout<<" \n INPUTKAN KODE TUJUAN ANDA [1/2]: ";
cin>>kode2;
switch(kode2)
{
case '1':
cout<<" \nBANGKOK";
cout<<"\nHARGA TIKET Rp$45";
break;
case '2':
cout<<" \nHONGKONG";
cout<<"\nHARGA TIKET Rp$55";
break;}getch();
break;
case 'X':
cout<<" EKONOMI";
cout<<" \n INPUTKAN KODE TUJUAN ANDA [1/2]: ";
cin>>kode2;
switch(kode2)
{
case '1':
cout<<" \nBANGKOK";
cout<<"\nHARGA TIKET Rp$55";
break;
case '2':
cout<<"\n HONGKONG";
cout<<"\nHARGA TIKET Rp$65";
break;}getch();
break;
} getch();
}
Langganan:
Postingan (Atom)