Help me in programming

Write your question here.
Which operator will be used here and why?

[u] I want to create a short program that is : User inputs 2 numbers answer should be shown which mathematics operator user wants to use i mean " +,-,/,% "
sorry for bad english
Last edited on
write in "Beginners" section to get answer quicker.

did you learn, cin/cout/ if/else ? you need these to program it.
Yes i have learnt it but I don't know how to assign variables in an If statement
char sign;
cin >> sign;

if(sign == '+')
{
//...do addition

}


http://www.learncpp.com/cpp-tutorial/52-if-statements/
What did we use char and equal to operator for?
you are more beginner than i thought.
start here http://www.cplusplus.com/doc/tutorial/
you need two variable that will hold the " 2 integers" and one for the operator
you may also use switch statements

1
2
3
4
5
6
switch ( operation ) {
case '+':/* add*/break;
case '-':/* subtract*/break;
case '*':/* multiply */break;
case '/': /* divide */ break;
}


you just have to imagine how your program will flow.

example:
you cannot compute/ solve a problem without seeing it
and then vice versa
Last edited on
Topic archived. No new replies allowed.