+ 2
Why is it doing this?
im trying to get it to ask user for 2 nums and add them then output it but it gives me a weird output. any idea? https://code.sololearn.com/c03a3yRkHj4v/?ref=app
2 ответов
+ 18
sum is being assigned the values of a and b before they are given values. All variables contain a garbage value before they're assigned something meaningful, which is where the weird result is coming from.
Place "sum = a + b;" after the cin instead.
+ 2
ohhhhh okay thank yiu man that makes alotnof sense actually 😂