Programalama > C++

Etiketler: switch, kullanimi

Ort. 0
Puan ver:
#include <iostream>

using std::cin;

using std::cout;

using std::endl;



int main() {

                  //variable declaretions

                  int num1,num2;

                  char operation;



                  //read two integer

                  cout<< “Enter two integer : ”;

                  cin>>num1>>num2;

                  

//read operation code

cout<< “Enter a select code:” <<endl;

            cout<< “         a for addition” <<endl;

            cout<< “         m for multiplication” <<endl;

            cout<< “         d for division   : ”; 

            cin>>operation;



            switch (operation){

            case ‘a’:

            case ‘A’ :

                        cout<< “The sum of the numbers is ”<<num1+num2<<endl;

case ‘m’:

            case ‘M’ :

                        cout<< “The product of the numbers is ”<<num1*num2<<endl;

case ‘d’:

            case ‘D’ :

                        cout<< “The division of the numbers is ”<<num1/num2<<endl;

            default :

                        cout<< “Operation code is not acceptable”<<endl;

}          

            

            return 0;

}


Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2024 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.