#C++ Basic calculator

47 messages · Page 1 of 1 (latest)

obsidian copper
#

im trying to make a calculator and my "else" statement isnt working

young mason
#

ok

obsidian copper
#

can i not paste my code in here?

#

it wont let me

young mason
#

wdym

obsidian copper
young mason
#

huh

#

can you paste it as a file?

obsidian copper
#

ok

slow marshBOT
#

@obsidian copper

yumoo. Uploaded Some Code
Uploaded these files to a Gist
obsidian copper
#

there

young mason
#

alright

obsidian copper
#

my issue is right here with my else

#

every time i try build it says i need a ; at the end of the else(option == 2)

#

like this

#

i thought u didnt need a ; at the end and only the {}

young mason
#

yeah you shouldn't need a semicolon there

#

one minute

obsidian copper
#

yea ik idk why its telling me to

#

ok

young mason
#

ohh

#

i missed it too

#

it's supposed to be else if

#

that fixes it

obsidian copper
#

oh

#

why's that?

#

i thought u do a else after a if statement

young mason
#

it may help to visualize it like ```cpp
if (/* ... /) {
// something
} else {
if (/
... */) {
// something else
}
}

obsidian copper
#

ooooh

#

i thought it needed a condition like if

#

ok ty for the help

young mason
#

there aren't enough c++ posts here

obsidian copper
#

lol

obsidian copper
#

ik its only one but i was told u could do more?

#

like i need to do 2 "-" but char is only one character so

obsidian copper
young mason
#

must be a string, and you can't switch with those :(

obsidian copper
#

i tried to use a string but it didnt work

#

yea

young mason
#

if else ig

obsidian flower
#

C++ Basic calculator