C++ Simple Calculator - On the previous post, writter have been explaining about Data Type. So, we can applying usability of Data Type for simple calculator. And we must understand about Operator Logic on C++ Programming.
The concept of C++ Simple Calculator :
- Insert two values in two variables
- procces the variables using operand.
- place the result of variables process in the other variable.
Than, we look below is the example of C++ Simple Calculator :
#include<iostream>You can use copy and paste that script on your compiler.
#include<windows.h>
using namespace std;
int main()
{
double a,b,c;
int x;
cout<<"======== MENU ======== \";
cout<<"[1] Addition \n";
cout<<"[2] Reduction \n";
cout<<"[3] Multiplication \n";
cout<<"[4] Division \n";
cout<<"[5] Exit \n";
cout<<"====================== \n";
cout<<"Enter number of your choice :
cin>>x;
switch(x){
case 1:
cout<<"Input value a :";
cin>>a;
cout<<"Input value b :";
cin>>b;
c=a+b;
cout<<"Result : "<<c<<"\n";
break;
case 2:
cout<<"Input value a :";
cin>>a;
cout<<"Input value b :";
cin>>b;
c=a-b;
cout<<"Result : "<<c<<"\n";
break;
case 3:
cout<<"Input value a :";
cin>>a;
cout<<"Input value b :";
cin>>b;
c=a*b;
cout<<"Result : "<<c<<"\n";
break;
case 4:
cout<<"Input value a :";
cin>>a;
cout<<"Input value b :";
cin>>b;
c=a/b;
cout<<"Result : "<<c<<"\n";
break;
case 5:
exit;
break;
default:
cout<<"Wrong number !\n\a";
}
}
Tested on :
Title : C++ Simple Calculator
OS : Windows
Compiler : Dev C++ Portable
Paper 4Share - C++ Simple Calculator
Comments
Post a Comment