|
// My first calculator//Abhi's calculator//
#include <iostream>
using namespace std;
float division (float a, float b)
{
float a1;
a1=a/b;
return (a1);
}
float multiplication (float c, float d)
{
int a2;
a2=c*d;
return (a2);
}
float addition(float e, float f)
{
int a3;
a3=e+f;
return(a3);
}
float subtraction(float g, float h)
{
int a4;
a4=g-h;
return(a4);
}
int main()
{
char user;
float ab;
float da;
float ans;
cout<<endl<<"welcome to="" abhi's="" calculator!"<<endl<<endl;
="" cout<<"(d)="Division(%)"<<endl;
" cout<<"(m)="Multiplication(*)"<<endl;
" cout<<"(a)="Addition(+)"<<endl;
" cout<<"(s)="Subtraction(-)"<<endl<<endl;
" cout<<"if="" you="" want="" division="" then="" press="" d="" or="" -="">"<<endl;
cout<<"if="" you="" want="" multiplication="" then="" press="" m="" or="" -="">"<<endl;
cout<<"if="" you="" want="" additionthen="" then="" press="" a="" or="" -="">"<<endl;
cout<<"if="" you="" want="" subtration="" then="" press="" s="" or="" -="">"<<endl<<endl;
cout<<"choose="" any="" one="" -="">"<<endl<<endl;
cin="">>user;
if (user == 'D' || user == 'd')
{
cout<<endl<<endl<<"what two="" numbers="" would="" you="" like="" to="" divide="" -="">"<<endl<<endl;
cout<<"enter="" 1st="" number="" -="">"<<endl;
cin="">>ab;
cout<<"Enter 2nd number ->"<<endl;
cin="">>da;
ans = division (ab,da);
cout<<"Answer is -> "<<ans;
}
="" if="" (user="=" 'm'="" ||="" user="=" 'm')
="" {
="" cout<<endl<<endl<<"what="" two="" numbers="" would="" you="" like="" to="" multiply="" -="">"<<endl<<endl;
cout<<"enter="" 1st="" number="" -="">"<<endl;
cin="">>ab;
cout<<"Enter 2nd number ->"<<endl;
cin="">>da;
ans = multiplication (ab,da);
cout<<"Answer is -> "<<ans;
}
="" if="" (user="=" 'a'="" ||="" user="=" 'a')
="" {
="" cout<<endl<<endl<<"what="" two="" numbers="" would="" you="" like="" to="" add="" -="">"<<endl<<endl;
cout<<"enter="" 1st="" number="" -="">"<<endl;
cin="">>ab;
cout<<"Enter 2nd number ->"<<endl;
cin="">>da;
ans = addition (ab,da);
cout<<"Answer is -> "<<ans;
}
="" if(user="=" 's'="" ||="" user="=" 's')
="" {
="" cout<<endl<<endl<<"what="" two="" numbers="" would="" you="" like="" to="" subtract="" -="">"<<endl<<endl;
cout<<"enter="" 1st="" number="" -="">"<<endl;
cin="">>ab;
cout<<"Enter 2nd number ->"<<endl;
cin="">>da;
ans = subtraction (ab,da);
cout<<"Answer is -> "<<ans;
}
="" cout<<endl<<"do="" you="" want="" to="" continue"<<endl<<endl;
="" {
="" char="" a;
="" cout<<"yes="" !="" -=""> press Y or y for yes"<<endl<<endl;
cout<<"no="" !="" -=""> press N or n for no"<<endl<<endl;
cin="">>a;
if(a=='y' || a=='Y')
{
main();
}
else if(a=='N' || a=='n')
{
cout<
|
|
|
|
|
what is this? why you post this code here?
|
|
|
|
|
What's the question?
If you want to share this calculator, then write a tip or an article:
Code Project Article FAQ[^]
In some cases, my signature will be longer than my message...
<em style="color:red"> <b>ProgramFOX</b></em> ProgramFOX
|
|
|
|
|
what's your question ?
warning ?
|
|
|
|