Tuesday, 17 June 2014

C++ program to implement menu driven calculator


Here is a C++ program to implement menu driven calculator


 SOURCE CODE OUTPUT
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
   int c,a,b;
   float result;
   cout<<"Program of a mini calculator:\n1  Addition\n2  Subtraction\n3  Multiplication\n4  Division\n5  Modulus\nEnter your choise: ";
   cin>>c;
   cout<<"Enter numbers : ";
   cin>>a>>b;
   switch(c)
   {
   case 1:
        result=a+b;
        break;
   case 2:
        result=a-b;
        break;
   case 3:
        result=a*b;
        break;
   case 4:
        result=a/b;
        break;
   case 5:
        result=a%b;
   default:
        cout<<"Wrong choise!!!";
        break;
   }
   cout<<"Answer is: "<<result;
   return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment