Monday, 3 November 2014

How To Make A Calculator In Turbo C++

I am learning Turbo C++ and thanks to my friend +ankit dubey for helping me whenver I face problems in using this tool and syntax. Here's my first tool and also I am pushing the source code for beginners like me who can make their own calculator with modification. 

Features:

  • Memu
  • Addition
  • Subtraction
  • Multiplication
  • Division
  • Written for newbies :D or I must say written by a newbie :D





Not talking about anything else, here's the source code:


#include<conio.h>
#include<stdio.h>
#include<fstream.h>
#include<math.h>
#include<process.h>
void main()
{       clrscr();
unsigned int choice;
cout<<"\n\t\t\tWelcome To Calculator By Rohan Arya\n";
cout<<"\n\t\t\tPress 1 For Addition\n";
cout<<"\n\t\t\tPress 2 For Subtraction\n";
cout<<"\n\t\t\tPress 3 For Multiplication\n";
cout<<"\n\t\t\tPress 4 For Division\n";
cout<<"\n\t\t\tPress 5 To Exit The Tool\n";
                {       cout<<"";}
                cin>>choice;
                while(choice==1)
                {
int a,b,c;
clrscr();
cout<<"\n\t\t\tAddition\n";
printf("Enter The First Number ");
scanf (" %d",&a);
printf("Enter The Second Number ");
scanf (" %d",&b);
c=a+b;
printf("The Answer is %d",c);
getch();
exit (0);
                 }
                 while(choice==3)
                 {
                int d,e,f;
clrscr();
cout<<"\n\t\t\tMultiplicaion\n";
printf("Enter The First Number ");
scanf ("%d",&d);
printf("Enter The Second Number ");
scanf ("%d",&e);
f=d*e;
printf("The Answer is %d",f);
getch();
exit (0);
                 }
                 if(choice==4)
                 {
int g,h,i;
clrscr();
cout<<"\n\t\t\tDivision\n";
printf("Enter The First Number ");
scanf ("%d",&g);
printf("Enter The Second Number ");
scanf ("%d",&h);
i=g/h;
printf("The Answer is %d",i);
getch();
exit (0);
                 }
                 if(choice==2)
                 {
int j,k,l;
clrscr();
cout<<"\n\t\t\tSubtract\n";
printf("Enter The First Number ");
scanf ("%d",&j);
printf("Enter The Second Number ");
scanf ("%d",&k);
l=j-k;
printf("The Answer is %d",l);
getch();
exit (0);
                 }
if(choice!=1&&choice!=2&&choice!=3&&choice!=4&&choice!=5)
                 {      cout<<"entered wrong choice PROGRAM IS ABORTING!!!!!!";
                        getch();
                        exit(0);
                 }
if(choice==5)
{
exit(0);
}
        }
getch();
Download the source code file:  http://goo.gl/mq1TxW
Here's the executable file: http://goo.gl/qGt5vh


If you have suggestions to make this tool better, then do comment below! :)

0 comments:

Post a Comment