how to make a modified calculator in C++ ???? please help ...
@Callisto
@dan815
please help...
hi
what do u want ur calculator to do
do you need to make interface for a calculator?? or actually write functions for calculator operations
yes
actually write functions for calculator operations
@dan815
@mathslover
@myininaya
Use math library, perhaps?
calculator that perform this
answer please
Can't see that clearly.
wait
here's my answer but i don't know how put the loop #include <iostream> using namespace std; int main() { int a=0; char op; do { int number1, number2; cout <<a<<endl; cout << "Input a number: "; cin >> number1; cout << "Input a valid operator: "; cin >> op; cout << "Input another number: "; cin >> number2; switch (op) { case '+': cout << "The answer is: " << number1 + number2 << endl; break; case '-': cout << "The answer is: " << number1 - number2 << endl; break; case '*': cout << "The answer is: " << number1 * number2 << endl; break; case '/': cout << "The answer is: " << number1 / number2 <<endl; break; default: cout << "operator invalid." << endl; } cout<< "do you want to calculate again? (C or Q)"; cin >> op; } while (op == 'C'); return 0; }
How do you know how many input numbers / operators are there for "one calculation"?
its depends to the users
what should i do to perform more than 2 numbers and operation by using loop
while (op != '=')
yes
nice ka...
thank you...
Huh? You got that?
awwww.
sorry there is still a lack...
the number are only performing 2 numbers
i need to perform 4 numbers in the second
lol, wait
okok
@ganeshie8
@Callisto
ok
It shouldn't work LOL
I think you need to rewrite your programme
its still the same
I mean you need to *rewrite* your programme.
can you help me??
I need to go soon...
#include <iostream> using namespace std; void main () { char choice='C'; do{ char symbol1; int count = 1, result1=0; int x, y; cout<<"Initial value= "<<result1<<endl;// this will display the initial value to the user cout<<"Input number: ";//input the two integers cin>>x; cout<<"Input operation: "; cin>>symbol1; cout<<"Input number: "; cin>>y; switch (symbol1) { case '+': result1= x + y; break; case '-' : result1 = x-y; break; case '/': result1 = x/y; break; case '*': result1 = x*y; } int a, result = result1; char symbol ; do{ cout<<"Input operation: "; cin>>symbol; if (symbol == '=') continue; cout<<"Input number: "; cin>>a; count++; switch (symbol) { case '+': result = result + a; break; case '-': result = result -a; break; case '/': result = result /a; break; case '*': result = result *a; break; } }while(symbol!='='); cout<<"Result: "<<result<<endl; cout<<"[Q]Quit or [C]Repeat Program\n"; do{cin>>choice; }while(choice!='C'&&choice!='c'&&choice!='q'&&choice!='Q'); cout<<endl<<endl; }while(choice=='C'||choice=='c'); }
please...
Do the order of operations matter?
If you do multiplications and divisions first, then this programme should work. I believe this is not good though. Feel free to modify it. Ask if you have any questions.
thanks :)
Join our real-time social learning platform and learn together with your friends!