Do While Sederhana pada C++
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void main()
{ int jwb;
char mad;
do
{ system("cls");
cout<<"=========================\n";
cout<<"| Menu Pilihan |\n";
cout<<"=========================\n\n";
cout<<"| 1. Baca Data |\n";
cout<<"| 2. Ubah Data |\n";
cout<<"| 3. Hapus Data |\n";
cout<<"| 4. Exit |\n";
cout<<"=========================\n";
masuk:
cout<<"Pilihan Anda 1-4: ";
cin>>jwb;
if(jwb==1)
{
cout<<"Anda Memilih Menu 1";
cout<<endl;
}
else
if(jwb==2)
{
cout<<"Anda Memilih Menu 2";
cout<<endl;
}
else
if(jwb==3)
{
cout<<"Anda Memilih Menu 3";
cout<<endl;
}
else
if(jwb==4)
exit(1);
else
{
cout<<"Pilihan (n) deret anda tidak tersedia\n";
cout<<"Mohon di inputkan kembali pilihan anda.\n";
goto masuk;
}
cout<<"\n\n Apakah anda ingin input data lagi(Y/T)? : ";
cin>>mad;
}
while(mad=='Y'||mad=='y');
cout<<"\n **** SELAMAT ANDA BERHASIL ****\n";
}
#include<conio.h>
#include<stdlib.h>
void main()
{ int jwb;
char mad;
do
{ system("cls");
cout<<"=========================\n";
cout<<"| Menu Pilihan |\n";
cout<<"=========================\n\n";
cout<<"| 1. Baca Data |\n";
cout<<"| 2. Ubah Data |\n";
cout<<"| 3. Hapus Data |\n";
cout<<"| 4. Exit |\n";
cout<<"=========================\n";
masuk:
cout<<"Pilihan Anda 1-4: ";
cin>>jwb;
if(jwb==1)
{
cout<<"Anda Memilih Menu 1";
cout<<endl;
}
else
if(jwb==2)
{
cout<<"Anda Memilih Menu 2";
cout<<endl;
}
else
if(jwb==3)
{
cout<<"Anda Memilih Menu 3";
cout<<endl;
}
else
if(jwb==4)
exit(1);
else
{
cout<<"Pilihan (n) deret anda tidak tersedia\n";
cout<<"Mohon di inputkan kembali pilihan anda.\n";
goto masuk;
}
cout<<"\n\n Apakah anda ingin input data lagi(Y/T)? : ";
cin>>mad;
}
while(mad=='Y'||mad=='y');
cout<<"\n **** SELAMAT ANDA BERHASIL ****\n";
}
Comments
Post a Comment
Terimakasih telah berkunjung dan berkomentar disini...