0
Should i have something incorrect ..if then plzz suggest me ! I want to made a calculator .
6 Respuestas
+ 2
:)
+ 1
It is an simple example , you can make it more advance as per your requirements.
If this helps☺️☺️.
https://code.sololearn.com/coT5vS5enflE/?ref=app
0
#include <iostream>
using namespace std ;
int sum(int a, int b)
{
return a+b ;
}
int sub(int c, int d)
{
return c-d ;
}
int mul(int e, int f)
{
return e*f ;
}
int divide(int g, int h)
{
return g/h;
}
int main ()
{
int i;
int j;
cin>>i>>j;
cout<<"Sum: "<<sum(i,j)<<endl;
cout<<"Sub: "<<sub(i,j)<<endl;
cout<<"Mul: "<<mul(i,j)<<endl;
cout<<"Div: "<<divide(i,j)<<endl;
return 0 ;
}
corrected your code a bit
0
okay that's perfect . But I want to create that calculator that computes only one thing either sum/sub/div/mul ..
so I want to promote the user of calculator to choose what he/she want to go for .
pls sir give some advice :)
0
you can make a user to write the expression e.g. 2+4 and use a char to store the + sign, then use a switch statement to check what symbol did the user enter
0
thanks meet mehta