Sunday, 25 September 2011

SIMPLE BASIC CALCULATOR PROGRAM WITH C++


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


main()
{
   int x, y;
   char op;
   cout <<"\t\t********** SIMPLE BASIC CALCULATOR ***********\n\n";
 N:cout << "\n\nEnter two integers:\n\n";
   cin >> x >> y;
   cout << "\nEnter an operator: ";
   cin >> op;
   cout << "\nResult is : ";
   switch (op) {
      case '+' : cout << (x + y)           << endl; break;
      case '-' : cout << (x - y)    << endl; break;
      case '*' : cout << (x * y)    << endl; break;
      case '/' : cout << (float(x)/float(y))<< endl; break;
      case '%' : cout << (x % y)    << endl; break;
   }
   char ch;
   cout << "\nDo you want to perform another operation (y/n)? :";
   cin >> ch;
   if (ch == 'y' || ch == 'Y')
   goto N;
   else
   cout << "\n\n\n\Thanks for using this program ! \t Press any key to exit......@devesh";
   getch();
}





Write this code on your turbo C, borland C++ or dev C++, window and run you will find a simple basic calculator for basic calculation like addition, subtraction, multiplication etc.

No comments:

Post a Comment