C++ Programming Blog

 
 
 

Image

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

 main()
    {
       clrscr();

       int value_1;
       int value_2;
       int result;
       int unknown=0;

       char optr;

       cout<<\"\\n Enter the Value_1 = \";
       cin>>value_1;

       cout<<\"\\n Enter the operator ( optr ) = \";
       cin>>optr;

       cout<<\"\\n Enter the Value_2 = \";
       cin>>value_2;

       switch(optr)
      {
         case \'+\' : result=value_1+value_2;
            break;

         case \'-\' : result=value_1-value_2;
            break;

         case \'*\' : result=value_1*value_2;
            break;

         case \'/\' : result=value_1/value_2;
            break;

         default : cout<<\"\\n Unknown Operator \"<<endl;
               unknown=1;
      }

       if(unknown==0)
      cout<<\"\\n Result = \"<<result<<endl;

       getch();
       return 0;
    }