C++ coding to make a calculator

C++ program to make a calculator

Hello guyz today will tell you that how to make a C++ perform that will  perform that arithmetical operation  which are present in menu in sort it is a type of calculator only. The coding  is bit big but if u will try to read and understand. You will find it easy… So the programming for the calculator is
_______________________________________________________________________________
#include<iostream.h>
#include<conio.h>
#include<math.h>
void  main() {
clrscr() ;
char ch ;
char name[20];
char chp;
char ap;
float a,b,c,d,e,result;
cout<<"Enter the name of the user:";
cin>>name;
cout<<"\t\t\t\t [1] Calculator Menu ";
cout<<"\n1.Add(+)\n2.Subtraction(-)\n3.Multiply(*)\n4.Division(/)\n5.Pythagouros Therom(p)\n6.Exponent(e)"<<endl;
cout<<"Enter the serial number of the operation you want to perform:";
cin>>ch;

if(ch =='1'){
cout<<"\n\t\t\tYou selected  addition"<<endl;
cout<<"\nEnter the value of A:";
cin>>a;
cout<<"Enter the value of B:";
cin>>b;
 result=a+b;
 cout<<"Sum of "<<a<<" and "<<b <<" will be:"<<result<<endl;}
 else
  if(ch =='2'){
  cout<<"\n\t\t\tYou selected Subtraction"<<endl;
  cout<<"Enter the value A:";
  cin>>a;
  cout<<"Enter the value of B:";
  cin>>b;
  result=a-b;
  cout<<"Diffrence between "<<a<<" and "<<b<<" will be:"<<result<<endl;}
  else
   if(ch =='3') {
   cout<<"\n\t\t\tYou selected Multiplycation"<<endl;
   cout<<"Enter the value of A:";
   cin>>a;
   cout<<"Enter the value of B:";
   cin>>b;
   result=a*b;
   cout<<"Product of "<<a<<" and "<<b<<" will be:"<<result<<endl;
    }
   else
    if(ch =='4'){
    cout<<"\n\t\t\tYou selected Division"<<endl;
    cout<<"Enter the value of A:";
    cin>>a;
    cout<<"Enter the value of B:";
    cin>>b;
    result=a/b;
    cout<<"Answer after dividing will be:"<<result<<endl;   }
     else
      if(ch=='5') {
      cout<<"\n\t\t\tYou selected Pythagouras theoram"<<endl;
      cout<<"\t\t\t\tSide Chart";
       cout<<"\n1.Perpendicular(p)\n2.Base(b)\n3.Hypoteneus(h)"<<endl;
       cout<<"Enter the serial number of the side you to want to find out:";
       cin>>chp;
       if
       (chp=='1') {
       cout<<"Enter the value of base:";
       cin>>c;
       cout<<"Enter the value of Hyputuneous:";
       cin>>d;
       e=sqrt(d*d-c*c);
       cout<<"The value of the perpendicular:"<<e<<endl;    }
       else
             if (chp=='3') {
             cout<<"Enter the value of perpendicular:";
             cin>>c;
             cout<<"Enter the value of base:";
             cin>>d;
             e=sqrt(c*c+d*d);
             cout<<"The value of the Hypotuneous:"<<e<<endl;  }
              else
              if(chp=='2') {
              cout<<"Enter the value of Hypotenuse:";
              cin>>c;
              cout<<"Enter the value of Perpendicular:";
              cin>>d;
              e=sqrt(c*c-d*d);
              cout<<"The value of the base:"<<e<<endl;}
             else
              cout<<"\a\aPlease rerun the program and choose the correct the option"<<endl; }
              else
              if(ch=='6') {
              cout<<"\n\t\t\tYou selected exponents"<<endl;
              cout<<"Enter the value of A:";
              cin>>a;
              cout<<"Enter the power of A:";
              cin>>b;
              c=pow(a,b);
              cout<<"The answer will be:"<<c<<endl; }
              else
     cout<<"Please rerun the program and choose the correct operation "<<name<<endl;


cout<<"Thanks for the program "<<name;
getch();
}

____________________________________________________________________________


To download click on Download icon↴
Image result for download

I know its bit big coding but it is simple so I hope you will understand and enjoy running it..
When you will run this program then it will first ask the user’s name the a chart will appear  which will have multiple arithmetic operations .. the appearance will be like this


Now enter the number and enter the value I hope you will like it..
If you want to further modify it then go on and enjoy…
If you want any other c++ program cooding  then just comment below


#For more C++ coding visit here:-
http://codingrockerzz.blogspot.com/









Comments

Popular posts from this blog

C++ program to find square root of a number

C++ program to find factorial

C++ program to make a Fibonacci Series