#include <conio.h>
#include <iostream>
using namespace std;
int main()
{
int pilih,angka,perkalian;
char a;
atas:
cout<<"|---------------------------------------------|"<<endl;
cout<<"| PERKALIAN DENGAN BERBAGAI FUNGSI PERULANGAN |"<<endl;
cout<<"|_____________________________________________|"<<endl;
cout<<"| 1. FOR NAIK |"<<endl;
cout<<"| 2. FOR TURUN |"<<endl;
cout<<"| 3. WHILE NAIK |"<<endl;
cout<<"| 4. WHILE TURUN |"<<endl;
cout<<"| 5. DO-WHILE NAIK |"<<endl;
cout<<"| 6. DO-WHILE TURUN |"<<endl;
cout<<"|_____________________________________________|"<<endl<<endl;
cout<<"Masukkan Pilihan Anda : ";
cin>>pilih;
if (pilih==1)
{
cout<<"PERKALIAN MENGGUNAKAN FOR NAIK "<<endl<<endl;
cout<<"Masukkan Nilai Perkalian : ";
cin>>perkalian;
for(angka=1;angka<=10;angka++)
{
cout<<angka<<" x "<<perkalian<<" = "<<(angka*perkalian)<<endl;
} //.....................................................................................
}
else if(pilih==2)
{
cout<<"PERKALIAN MENGGUNAKAN FOR TURUN"<<endl<<endl;
cout<<"Masukkan Nilai Perkalian : ";
cin>>perkalian;
for(angka=10;angka>=1;angka--)
{
cout<<angka<<" x "<<perkalian<<" = "<<(angka*perkalian)<<endl;
}//...........................................................................................
}
else if (pilih==3)
{
cout<<"PERKALIAN MENGGUNAKAN WHILE NAIK "<<endl<<endl;
cout<<"Masukkan Nilai Perkalian : ";
cin>>perkalian;
while(angka<=10)
{
cout<<angka<<" x "<<perkalian<<" = "<<(angka*perkalian)<<endl;
angka++;
}//..............................................................................................
}
else if (pilih==4)
{
cout<<"PERKALIAN MENGGUNAKAN WHILE TURUN "<<endl<<endl;
cout<<"Masukkan Nilai Perkalian : ";
cin>>perkalian;
while(angka>=1)
{
cout<<angka<<" x "<<perkalian<<" = "<<(angka*perkalian)<<endl;
angka--;
}//..................................................................................................
}
else if(pilih==5)
{
angka=1;
cout<<"PERKALIAN MENGGUNAKAN DO-WHILE NAIK "<<endl<<endl;
cout<<"Masukkan Nilai Perkalian : ";
cin>>perkalian;
do
{
cout<<angka<<" x "<<perkalian<<" = "<<(angka*perkalian)<<endl;
angka++;
}
while(angka<=10);
}//..........................................................................................
else if (pilih==6)
{
angka=10;
cout<<"PERKALIAN MENGGUNAKAN DO-WHILE TURUN"<<endl<<endl;
cout<<"Masukkan Nilai Perkalian : ";
cin>>perkalian;
do
{
cout<<angka<<" x "<<perkalian<<" = "<<(angka*perkalian)<<endl;
angka--;
}
while(angka>=1);
}//.................................................................................................
else
{
cout<<"PILIHAN MENU TIDAK ADA ... "<<endl;
}
cout <<endl<<endl<<"Kembali ke Menu? [Y/N] ===> ";cin>>a;
if (a=='Y'|| a=='y')
goto atas;
return 0;
}
No comments:
Post a Comment