Kalkulator Sederhana

Script untuk membuat kalkulator sederhana yang berisikan perhitungan perhitungan aritmetika, relasi, logika dan betwise dengan menggunakan program Min GW Developer Studio. 


Contoh Script

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

int main()
{
            awal:
            {system("cls");
            int jawaban;
            cout<<"=====================================\n";
            cout<<"         PROGRAM KALKULATOR\n";
            cout<<"      ANGGAR NUR HERMAN SYAH\n";
            cout<<"            esokharinanti.blogspot.com\n";
            cout<<"=====================================\n";
            cout<<"1. Operator Aritmatika \n";
            cout<<"2. Operator Relasi \n";
            cout<<"3. Operator Logika \n";
            cout<<"4. Operator Bitwise \n";
            cout<<"=====================================\n";
            cout<<"Pilih sesuai selera [1-4]:";cin>>jawaban;
           
            if (jawaban==1){goto aritmetika;}
            else if (jawaban==2){goto relasi;}
            else if (jawaban==3){goto logika;}
            else if (jawaban==4){goto bitwise;}
            }
            aritmetika:
            {system("cls");
            cout<<"===============================\n";
            cout<<"         HASIL PERHITUNGAN\n";
            cout<<"             ARITMETIKA\n";
            cout<<"      esokharinanti.blogspot.com\n";
            cout<<"===============================\n";
            int a, b ;
            char jawab;
            cout<<"Masukkan nilai A:";cin>>a ;
            cout<<"Masukkan Nilai B:";cin>>b ;
            cout<<a<<" + "<<b<<" = "<<a+b<<endl;
            cout<<a<<" - "<<b<<" = "<<a-b<<endl;
            cout<<a<<" * "<<b<<" = "<<a*b<<endl;
            cout<<a<<" / "<<b<<" = "<<a/b<<endl;
            cout<<a<<" % "<<b<<" = "<<a%b<<endl;
            getch ();
            cout<<"Kembali ke menu awal (Y/T)?: ";cin>>jawab;
           
            if (jawab=='Y'||jawab=='y'){goto awal;}
            else if (jawab=='T'||jawab=='t'){goto akhir;}
            }
           
            relasi:
            {system("cls");
            cout<<"===============================\n";
            cout<<"         HASIL PERHITUNGAN\n";
            cout<<"                RELASI\n";
            cout<<"      esokharinanti.blogspot.com\n";
            cout<<"===============================\n";
            int m , n ;
            char jawab;
            cout<<"Masukkan nilai A:";cin>>n ;
            cout<<"Masukkan Nilai B:";cin>>m ;
            if (m == n) cout<<m<<" Sama Dengan "<<n<<endl;
            else if (m != n) cout<<m<<" Tidak Sama Dengan  "<<n<<endl;
            else if (m > n) cout<<m<<" Lebih Besar Dari "<<n<<endl;
            else if (m < n) cout<<m<<" Lebih Kecil Dari "<<n<<endl;
            cout<<"Kembali ke menu awal (Y/T)?: ";cin>>jawab;
           
            if (jawab=='Y'||jawab=='y'){goto awal;}
            else if (jawab=='T'||jawab=='t'){goto akhir;}
            }

            logika:
            {system("cls");
            cout<<"===============================\n";
            cout<<"         HASIL PERHITUNGAN\n";
            cout<<"               LOGIKA\n";
            cout<<"      esokharinanti.blogspot.com\n";
            cout<<"===============================\n";
            int k;
            char jawab;
            cout<<"Masukkan nilai :";cin>>k;
            cout<<"(k>=0 && k<=150) -> "<<(k>=0 && k<=150)<<endl;
            cout<<"(k>=0 || k<=150) -> "<<(k>=0 || k<=150)<<endl;
            cout<<"Kembali ke menu awal (Y/T)?: ";cin>>jawab;
           
            if (jawab=='Y'||jawab=='y'){goto awal;}
            else if (jawab=='T'||jawab=='t'){goto akhir;}
            }

            bitwise:
            {system("cls");
            cout<<"===============================\n";
            cout<<"         HASIL PERHITUNGAN\n";
            cout<<"              BITWISE\n";
            cout<<"      esokharinanti.blogspot.com\n";
            cout<<"===============================\n";
            int f;
            char jawab;     
            cout<<"Masukan Nilai X = ";
            cin>>f;
            f = f << 1; //geser ke kiri 1 bit
            cout<<"Hasil dari Geser 1 Bit Kekiri = "<<f<<endl;
            cout<<"Kembali ke menu awal (Y/T)?: ";cin>>jawab;
           
            if (jawab=='Y'||jawab=='y'){goto awal;}
            else if (jawab=='T'||jawab=='t'){goto akhir;}
            }
            akhir:
            {system("cls");
            return 0;
            }

}

Berlangganan update artikel terbaru via email:

0 Response to "Kalkulator Sederhana"

Post a Comment

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel