-
-
and the Hat of Guessing
Originally Posted by
godofal
so use if statements?
Sounds like a plan to me. If you read in the op as a single character, you can get really fancy and use switch.
-
well, i used those if statements, and it works now!
i had some difficulties becouse i used = instead of == first, but figured that out, and now it works olmost completely as it should.
the 2 issues i still have are that i needed to use numbers instead of operators. so in the program, 1 represents +, 2 means -, 3 uses *, and 4 /.
and, i cannot use decimal(not sure if theyr called that way) numbers like 1.5, just whole numbers like 1...
im think ive read somewhere how to fix that first issue, and maybe i can fix the second also.
i have included the code in this reply.
edit:
i have used long double to make decimal numbers possible, ive tested it and it works
edit2:
i cant get OP1 to accept characters like +,-,* or /
i have tried making OP1 a char integer, and use the:
if ( OP1 == + ) {
NR3= NR1 + NR2; //use if OP1 is 1 (+)
}
statement (and the other operators likewise)
but codeblocks says:
main.cpp|20|error: expected primary-expression before ')' token|
how do i get this to work??
Last edited by godofal; 03-19-2010 at 07:03 AM.
-
and the Hat of Guessing
+ is not a character. '+' is a character.
-
im going to try that next!
*crosses fingers*
it works
ive included the finished sourcecode.
Last edited by godofal; 03-19-2010 at 12:45 PM.
Popular pages
Recent additions