Re: If else statement displaying both options.
Quote:
Originally Posted by
Arjay
Initialize your variables means to declare them and then set them. You can do this all in one step. In C++, initializing variables prevents a variable from starting out with garbage and it's a good practice to get into (because they are often a source of bugs).
Code:
int x; // uninitialized variable it's anyone's guess what its starting value will be.
int y = 0; variable declared and initialized to 0
So if I want the variable to be something the user enters, how do I initialize it?
Re: If else statement displaying both options.
Quote:
Originally Posted by
VictorN
Sorry, I despise forums and only did this one to get help from the community because I thought it would be very useful, so I had no idea about things like this.
Re: If else statement displaying both options.
Quote:
Hi, I am new to coding
You might like to look at these sites
http://www.learncpp.com/
http://www.cplusplus.com/doc/tutorial/
Going back to your issue re numbers being considered small.
As suggested earlier, the problem is cin.ignore() which ignores the next character. So if you entered 21, it would be considered as 1 and 67 would be considered as 7 etc.
Re: If else statement displaying both options.
Quote:
Originally Posted by
Sensei Nacho
Sorry, I despise forums and only did this one to get help from the community because I thought it would be very useful, so I had no idea about things like this.
Not sure what there is to despise about forums where volunteers help folks solve issues without compensation or in many cases, thanks.
Re: If else statement displaying both options.
Quote:
Originally Posted by
Sensei Nacho
Quote:
Before posting, please format your code properly and use code tags. Go advanced, select the code and click '#'.
How do I do this?
What don't you understand about the instruction given? Press the 'Go Advanced' button, select the code using normal selection process and then click the '#' button.