Halaman

Jumat, 18 April 2014

Contoh Menu bahasa c++

#include <iostream.h>
#include <conio.h>
main()
{
int pil,i,j,m,n;
float a;
char k;
char l='A';
clrscr();
menu:


cout<<"==== MENU ==== ";
cout<<"\n1. DERET 1 ";
cout<<"\n2. DERET 2 ";
cout<<"\n3. DERET 3 ";
cout<<"\n4. EXIT ";
cout<<"\n PILIHAN ANDA : " ; cin>>pil;
switch(pil){




case 1:
 for(i=5;i>=1;i-=1) {
 k='A';
 cout <<"\n";
 for(j=1;j<=i;j+=1)
 if(i%2==0)
 cout <<k++<<" ";
 else
 cout <<j<<" ";
 }
getch();
goto menu;

case 2:
m = 11;
 for(i=1;i<=5;i++) {
 cout<<"\n";
 for(j=1;j<=i;j++)
 if(i<=4)
 cout <<l++<<" ";
 else
 cout <<m++<<" ";
 }

getch();
goto menu;


case 3:
cout<<"masukkan angka : ";
cin>>n;
while(n>0){
cout<<n<<",";
n--;
}
cout<<"\nberhenti";
getch();
goto menu;


case 4:
cout<<"exit";
break;

default:
cout<<"\n\npilihan hanya 1, 2, 3 dan 4 \n\n\n ";
goto menu ;
}
return 0;
}

Tidak ada komentar:

Posting Komentar