Hi , im finding it really hard to understand how boolen works
and how it supposed to be used. Iv read all tutorials and i still cant understand any help please.
Thanks
Hi , im finding it really hard to understand how boolen works
and how it supposed to be used. Iv read all tutorials and i still cant understand any help please.
Thanks
It's a truth value. It can be true or false. What part do you have problems with? Logical operations? If statements? Loops?
It's boolean, by the way.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
im having a problem understanding on how to write a code with it up to now iv done this. But when the user enters coke how do i get it to say you have a bought a coke.
Code:string coke1 = "coke"; bool coke = true; bool cokef =(false); cout <<"Enter coke to buy" << endl; cin >> coke1;
Remove the lines declaring the two bool variables, and add this after the cin line.
Code:bool typed_coke = (coke1 == "coke"); if (typed_coke) cout << "You typed in coke\n"; else cout << "You typed in something else\n"; cout << "Another way that is useful sometimes, although it can make code harder to understand\n"; cout << "You typed in " << (typed_coke ? "coke" : "something else") << '\n';
Last edited by grumpy; 07-14-2012 at 07:43 PM. Reason: Incorporate correction from King Mir in later post
thats a bit complicated for me as im a beginner
The amount of spoon-feeding on offer here is finite.
The first four lines in the code fragment I gave are an absolute minimum that a beginner needs to work with booleans.
what dose typed mean i havent come across that yet
In the sense that I used it ....
The word suffix "ed" has the effect of "forming the past tense of a weak verb". In other words it converts the present tense "I type this post" into the past tense "I typed this post".Originally Posted by English language dictionary
There is an assumption here that you understand the english language, or will look up basic things like that if you don't understand.
Thanks for the correction, King Mir. I'll edit my preceding post accordingly.
best thing I've learned (as I am a beginner too) is if you don't understand something, you may not be ready to tackle it yet.. I've often gone back and re learned the things I already knew, until whatever I was struggling with just kinda clicked..
Boolean only has 2 options- true or false.
also the people on the forums are very helpful, but don't expect them to complete your code for you through every step.