how to define operator

Jun 11, 2011 at 8:32pm
well i have an assignment which says i have to let the user enter
number1 (+,-,*,/) number2
then i have to print the number statement and show answer
example
2.1 * 3.5
is there a way i can define the + * / - operators or what do i do because i got no clue =x
Jun 11, 2011 at 9:07pm
Yes, you can overload those operators, but that's not what you need to do here at all. Basically, you get them to enter number1, then an operator (store it in a char), and then number2. Then just use a switch statement or if statements to do the right thing based on what operator they put in.
Jun 11, 2011 at 9:12pm
yea i figured it out =x but it seems i still did something wrong lol
can u see whats wrong because only thing that happens when i input the data is nothing lol it just ends
Last edited on Jun 11, 2011 at 9:26pm
Topic archived. No new replies allowed.