I need help with True, False, NOT, AND, OR, I know what they do but how do I use them in code?(btw I am a complete nobbie I just started like 2 days ago...) thanks! :)
Printable View
I need help with True, False, NOT, AND, OR, I know what they do but how do I use them in code?(btw I am a complete nobbie I just started like 2 days ago...) thanks! :)
That's a very open ended question.... You can use them in many, many scenarios..
AND/OR/NOT are represented as operators: &&/||/! respectively.. true and false are both keywords (false represents Zero, and true typically represents One), and are generally the 2 possible outcomes of any expression involving these operators.
Thanks Bench82 but I ment how do I use them in code I know what they do I just dont know how 2 use them... :)
Alright if you know how to use them then what are you doing here?
if you need examples you should know from what your getting the knoledge from.
//Enouph of the flame
Alright here are some examples.
its untested but those are examplesCode:
#include <iostream>//Basic Library
using namespace std;// Namespace for not typing out the whole function like so std::cout//
int main(){// You need int main for compiler even to read this.
int i=0,a=0; // Numbers only Thats 6 digit limit//
bool event; // True and False//
if(i==0 &&/* && means AND*/ a==0){ // example of AND
event=true;// example of True
event=false;//Example of false
}
if(event==true || event==false){ // example of or
i=1;
}
if(i != 0){//Example of Not
cout<<"i does not equal 0"<<endl;// This is Outputing whats inside of quotes//
system("PAUSE");// This pauses the system for you to see ouput //
}
}
OK - well, it's still a very open ended question... You might be better off looking at this tutorial.... http://www.cprogramming.com/tutorial/lesson2.htmlQuote:
Originally Posted by cgsarebeast
I have I need It more explaned basicly
Dude how basic do you need it I just gave you examples!!!
Srry like I said I just started 2 days ago, I dont know how 2 describe it, I guess It would be explaning thanks for ur help i'm a slow learner :)
...........Dude your not slow your just feeble minded .
I dont think no ones going to spoon feed you everything
that example was 2 advance if you can could u break it down (btw I'm only on lesson 3 of this sites help)
dude I am not lazy (well sort of lol :)) but I really am a slow learner and if u cant help me PLEASE dont make comments like that cuz u dont know me or if I am a slow learner or not!
but I do apresheate you help if you wanna give it (srry I'm a VERY bad speller)
Your kidding me if thats to advance then im god.
watch maybe your thinking this is code
//<--- its not those are comments anything after this is commented.
and
/* */ those are also comments anything between these are commented.
I need 2 put 2 -n- 2 tougther for ex. how would I use a True, False, AND, OR, NOT with text.... like how would I combinde the 2 things and it work, I dont know how else 2 desribe it... thanks though :)
right, first off. Learn to spell. if you can't even spell, coding is not for you. But I don't believe you can't spell, I think you're just being lazy.
I'll give you some starters:
- '2' is a number. 'to' is a word. They have different meanings.
- there is no such word in the english language as '-n-'. The word is
'and', and it takes the same amount of time to type!
edit: and if you still can't spell, use a spell checker!
You might think, I'm being pedantic (or just being an ..............), but when you code, if you make a speeling mistock, your code won't work.
as for your question, boolean logic (true, false, and, or, etc) is used to make decisions in a program.
Code:int age = 20;
if (age < 10) // evaluates to true
{
cout << "you are young"; // this means print "you are young" on the screen
}
else if (age >= 10 && age < 20) // this means if the age is greater than 10 AND less than 20
{
cout << "you are an adolescent";
}