+ 1

What is wrong with my code?

Hey guys, First of all thank you for your time in reading this. Being straight to the point, why doesn't my code work what am i missing below? #include <iostream> using namespace std; int main() { int a = 45; int b = a; cout << b + a << endl; cout << "whats happening \n"; cout << "everyone"; return 0; } { int maxsize; cin >> maxsize; if (maxsize > 200){ cout << "its ok go through \n"; if (maxsize < 200){ cout << "all good mate go through"; } } else{ cout << "Im afraid it's too big and it won't go in"; return 0; }

31st Jul 2018, 10:55 AM
Efil Van Erde
Efil Van Erde - avatar
7 Answers
31st Jul 2018, 2:07 PM
StealthyTaco
StealthyTaco - avatar
+ 1
everything has to reside within your main function or another function, everything after the } after return zero is out of scope and wont be executed so just move that big chunk into the function main and put return 0; } at the very end. thats just one error though i didnt check for anything else you can post your code so we can edit and further help you!
31st Jul 2018, 11:51 AM
StealthyTaco
StealthyTaco - avatar
+ 1
Hey guys thank you for the answers! Here is the link to my code. https://code.sololearn.com/cLx112pxLkXQ/#cpp
31st Jul 2018, 1:28 PM
Efil Van Erde
Efil Van Erde - avatar
+ 1
Hey Guys thank you for correcting my code. And thank you for pin pointing where i did wrong Robert.
31st Jul 2018, 3:34 PM
Efil Van Erde
Efil Van Erde - avatar
0
I caught the error. Please post your code link so I can improve the code and help you.
31st Jul 2018, 11:06 AM
Meet Mehta
Meet Mehta - avatar
31st Jul 2018, 1:38 PM
Meet Mehta
Meet Mehta - avatar
0
Tiago Silva anytime :)
31st Jul 2018, 4:04 PM
StealthyTaco
StealthyTaco - avatar