i need code for scientific calculator in vc++ by using switch case statement

Member Avatar for jencas

google("vc++ calculator");

>i need code for scientific calculator in vc++ by using switch case statement
So tell me what have you tried. Remember, we don't provide codes. We only help those who show efforts. Please try and then tell us on what part are you having problem.

i need code for scientific calculator in vc++ by using switch case statement

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{ 
    char ch[5];
  
  int op;
   
    system("color f3");
// if you have any more problems send me i will give you thhe answers ok

    cout<<"\t***********************MUZAMAL calculator**************************"<<endl;;
    cout<<endl;
   

while(1){
cout<<"\t1.addition"<<endl;
cout<<"\t2.subtrection"<<endl;
cout<<"\t3.division"<<endl;
cout<<"\t4.multiplication"<<endl;
cout<<"\t5.area of square"<<endl;

cout<<"enter your option"<<endl;
cin>>op;


cout<<"you slected "<<op<<endl;
switch(op){
           case 1:
                int a,c,sum;
                cout<<"enter the first number"<<endl;
                cin>>a;
                cout<<"enter the 2nd  number"<<endl;
                cin>>c;
                sum=a+c;
                cout<<"sum  =" <<sum<<endl;
                break; 
           case 2:
                int a1,c1,sub;
                cout<<"enter the first number"<<endl;
                cin>>a1;
                cout<<"enter the 2nd  number"<<endl;
                cin>>c1;
                sub=a1+c1;
                cout<<"subtrection  =" <<sub<<endl;
                break; 
            case 3:
                int a2,c2,div;
                cout<<"enter the first number"<<endl;
                cin>>a2;
                cout<<"enter the 2nd  number"<<endl;
                cin>>c2;
                div=a2/c2;
                cout<<"division  =" <<div<<endl;
                break; 
             case 4:
                int a3,c3,mult;
                cout<<"enter the first number"<<endl;
                cin>>a3;
                cout<<"enter the 2nd  number"<<endl;
                cin>>c3;
                mult=a3*c3;
                cout<<"multiply  =" <<mult<<endl;
                break; 
             case 5:
                int a4,area;float c4=3.14;
                cout<<"enter the radius"<<endl;
                cin>>a4;
                area=c4*(a4*a4)*(0.5);
                
                cout<<"area of square  =" <<area<<endl;
                break; }
                 }   
           
    system("PAUSE");
    return EXIT_SUCCESS;
}
commented: Another FREE LUNCH post! Stop doing homework for others. It's THEIR homework, not yours. -2

thanks for this. but can you help me how to understand or make program easy? :D puhleaase.. :D

thanks and more power to u

thanks for this ,but can you give me the value of sin,cos,tan and pi?
send it to my email <<snip>> :D

commented: NO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -4
commented: TANSTAAFL -2
commented: This is a Forum! +0

Oh, why not. 1, 0, 1, 3.14

i need code for scientific calculator in vc++ by using switch case statement

what the statement problem of scientific calculator?

commented: Don't bump old threads -1

thanks for the above program but pls how can i include tan, cos, sin, tan-1(tan inverse) e.t.c.

#include<iostream>
#include<conio.h>
#include<windows.h>
#include<cctype>
#include<cmath>
using namespace std;
int main ()
 char letter;
 char letter1;
 char letter2;
 char letter3;
 char letter4;
 int a,b;
 double a1,b1;
 int result;
 double result1;
 cout<<"\n\n\n ***************** SCIENTIFIC CALCULATOR ****************** \n\n\n";
do

        cout<<"\t 1 : Arithmetic Operations \n";
 cout<<"\t 2 : Trigonometric Functions \n";
 cout<<"\t 3 : Logarithmic Functions \n";
 cout<<"\t 4 : Power Functions \n";
 cout<<"\t 5 : Exit... \n";
 letter = getche();

 switch(letter)

case '1':

            cout<<"\n\n";
                 cout<<"\t1 : Addition \n";
          cout<<"\t2 : Subtraction \n";
          cout<<"\t3 : Multipilication \n";
          cout<<"\t4 : Division \n\n";
          letter1 = getche();
             switch(letter1)
              {
                case '1':
                         {
                              cout<<"\n\nEnter first number...";
                              cin>>a;
                              cout<<"Enter an other number...";
                        cin>>b;
                        result=a+b;
                        cout<<"\n\nResult = "<<result<<endl;
                        system("pause");
                        break;
                          }                 
                case '2':
                      {
                   cout<<"\n\nEnter first number...";
                              cin>>a;
                              cout<<"Enter an other number...";
                        cin>>b;
                   result=a-b;
                   cout<<"\n\nResult = "<<result<<endl;
                   system("pause");
                    break;
                        }

                case '3':
                         {
                   cout<<"\n\nEnter first number...";
                              cin>>a;
                              cout<<"Enter an other number...";
                        cin>>b;
                   result=a*b;
                   cout<<"\n\nResult = "<<result<<endl;
                   system("pause");
                    break;
                   }

                case '4':         
                          {
                      cout<<"\n\nEnter first number...";
                              cin>>a;
                              cout<<"Enter an other number...";
                        cin>>b;
                      if(a!=0)
                       {
                        result=a/b;
                          cout<<"\n\nResult = "<<result<<endl;
                          system("pause");
                       }
                             break;
                          }

              }// end of inner switch
              break;
        // end of case 1 arithmatic operation

 case '2':

          cout<<"\n\n";
    cout<<"\t1 : Sin function \n";
          cout<<"\t2 : Cos function \n";
          cout<<"\t3 : Tan function \n";
    letter2=getche();
    switch(letter2)
    {
    case '1':
     {
     cout<<"\n\n Enter a number...";
     cin>>a1;

     result1=(sin(a1));
     cout<<"\n\nResult = "<<result1<<endl;
     system("pause");
                 break;
     }
    case '2':
     {
    cout<<"\n\n Enter a number...";
     cin>>a1;
                                 result1=(cos(a1));
      cout<<"\n\nResult = "<<result1<<endl;
      system("pause");
      break;
     }
    case '3':
     {
    cout<<"\n\n Enter a number...";
     cin>>a1;
                                 result1=(tan(a1));
      cout<<"\n\nResult = "<<result1<<endl;
      system("pause");
      break;

     }

   // inner switch

     //inner case 2 trignomatic
    case '3':

           cout<<"\n\n";
    cout<<"\t1 : Natural log\n";
    cout<<"\t2 : log with base 10 \n";
    letter3=getche();
    switch(letter3)
    {
    case '1':
     {
    cout<<"\n\n Enter a number...";
     cin>>a1;
                                 result1=log(a1);
    cout<<"\n\n Result = "<<result1<<endl;
    system("pause");
    break;

    case '2':
     {
     cout<<"\n\n Enter a number...";
     cin>>a1;
            result1= log10(a1);
     cout<<"\n\n Result = "<<result1<<endl;
     system("pause");
     break;
     }
           }// end of switch
           break;
         }// end of case 3 logrithmic
    case '4':
         {
             system("cls");
    cout<<"1) Press 1 for Power \n";
    cout<<"2) Press 2 for Square root \n";
    cout<<"Enter your choice....";
    letter4=getche();
`

    #include<iostream>
    #include<conio.h>
    #include<windows.h>
    #include<cctype>
    #include<cmath>
    using namespace std;
    int main ()
    {
     char letter;
     char letter1;
     char letter2;
     char letter3;
     char letter4;
     int a,b;
     double a1,b1;
     int result;
     double result1;
     cout<<"\n\n\n ***************** SCIENTIFIC CALCULATOR ****************** \n\n\n";
    do
     {
            cout<<"\t 1 : Arithmetic Operations \n";
     cout<<"\t 2 : Trigonometric Functions \n";
     cout<<"\t 3 : Logarithmic Functions \n";
     cout<<"\t 4 : Power Functions \n";
     cout<<"\t 5 : Exit... \n";
     letter = getche();

     switch(letter)

     {
    case '1':

      {
              cout<<"\n\n";
                     cout<<"\t1 : Addition \n";
              cout<<"\t2 : Subtraction \n";
              cout<<"\t3 : Multipilication \n";
              cout<<"\t4 : Division \n\n";
              letter1 = getche();
                 switch(letter1)
                  {
                    case '1':
                             {
                                  cout<<"\n\nEnter first number...";
                                  cin>>a;
                                  cout<<"Enter an other number...";
                            cin>>b;
                            result=a+b;
                            cout<<"\n\nResult = "<<result<<endl;
                            system("pause");
                            break;
                              }                 
                    case '2':
                          {
                       cout<<"\n\nEnter first number...";
                                  cin>>a;
                                  cout<<"Enter an other number...";
                            cin>>b;
                       result=a-b;
                       cout<<"\n\nResult = "<<result<<endl;
                       system("pause");
                        break;
                            }

                    case '3':
                             {
                       cout<<"\n\nEnter first number...";
                                  cin>>a;
                                  cout<<"Enter an other number...";
                            cin>>b;
                       result=a*b;
                       cout<<"\n\nResult = "<<result<<endl;
                       system("pause");
                        break;
                       }

                    case '4':         
                              {
                          cout<<"\n\nEnter first number...";
                                  cin>>a;
                                  cout<<"Enter an other number...";
                            cin>>b;
                          if(a!=0)
                           {
                            result=a/b;
                              cout<<"\n\nResult = "<<result<<endl;
                              system("pause");
                           }
                                 break;
                              }

                  }// end of inner switch
                  break;
            }// end of case 1 arithmatic operation

     case '2':
             {
              cout<<"\n\n";
        cout<<"\t1 : Sin function \n";
              cout<<"\t2 : Cos function \n";
              cout<<"\t3 : Tan function \n";
        letter2=getche();
        switch(letter2)
        {
        case '1':
         {
         cout<<"\n\n Enter a number...";
         cin>>a1;

         result1=(sin(a1));
         cout<<"\n\nResult = "<<result1<<endl;
         system("pause");
                     break;
         }
        case '2':
         {
        cout<<"\n\n Enter a number...";
         cin>>a1;
                                     result1=(cos(a1));
          cout<<"\n\nResult = "<<result1<<endl;
          system("pause");
          break;
         }
        case '3':
         {
        cout<<"\n\n Enter a number...";
         cin>>a1;
                                     result1=(tan(a1));
          cout<<"\n\nResult = "<<result1<<endl;
          system("pause");
          break;

         }

       }// inner switch
        break;
             }//inner case 2 trignomatic
        case '3':
             {
               cout<<"\n\n";
        cout<<"\t1 : Natural log\n";
        cout<<"\t2 : log with base 10 \n";
        letter3=getche();
        switch(letter3)
        {
        case '1':
         {
        cout<<"\n\n Enter a number...";
         cin>>a1;
                                     result1=log(a1);
        cout<<"\n\n Result = "<<result1<<endl;
        system("pause");
        break;
       }
        case '2':
         {
         cout<<"\n\n Enter a number...";
         cin>>a1;
                result1= log10(a1);
         cout<<"\n\n Result = "<<result1<<endl;
         system("pause");
         break;
         }
               }// end of switch
               break;
             }// end of case 3 logrithmic
        case '4':
             {
                 system("cls");
        cout<<"1) Press 1 for Power \n";
        cout<<"2) Press 2 for Square root \n";
        cout<<"Enter your choice....";
        letter4=getche();
        switch(letter4)
        {
        case '1':
         {
          cout<<"\n\nEnter a number...";
          cin>>a1;
          cout<<"Enter power...";
          cin>>b1;
          result1=pow(a1,b1);
          cout<<"\n\nResult = "<<result1<<endl;
          system("pause");
          break;
         }
        case '2':
         {
          cout<<"\n\nEnter a number...";
          cin>>a;
          result1=sqrt(a);
          cout<<"\n\nResult = "<<result1<<endl;
          system("pause");
          break;

         }

        }// end of switch
               break;
             }// end of case power function

      }// outer switch
    }while(letter != '5');

     return 0;
    }

`    switch(letter4)

    case '1':
     {
      cout<<"\n\nEnter a number...";
      cin>>a1;
      cout<<"Enter power...";
      cin>>b1;
      result1=pow(a1,b1);
      cout<<"\n\nResult = "<<result1<<endl;
      system("pause");
      break;
     }
    case '2':
     {
      cout<<"\n\nEnter a number...";
      cin>>a;
      result1=sqrt(a);
      cout<<"\n\nResult = "<<result1<<endl;
      system("pause");
      break;

     }

    }// end of switch
           break;
         }// end of case power function

  // outer switch
while(letter != '5');

 return 0;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.