Thread: Help with True, False, NOT, AND, OR...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    18

    Exclamation Help with True, False, NOT, AND, OR...

    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!

  2. #2
    Registered User
    Join Date
    Feb 2006
    Posts
    312
    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.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    18
    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...

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    34
    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.

    Code:
    #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 //
    }
    }
    its untested but those are examples

  5. #5
    Registered User
    Join Date
    Feb 2006
    Posts
    312
    Quote Originally Posted by cgsarebeast
    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...
    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.html

  6. #6
    Registered User
    Join Date
    May 2006
    Posts
    18
    I have I need It more explaned basicly

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    34
    Dude how basic do you need it I just gave you examples!!!

  8. #8
    Registered User
    Join Date
    May 2006
    Posts
    18
    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

  9. #9
    Registered User
    Join Date
    May 2006
    Posts
    34
    ...........Dude your not slow your just feeble minded .
    I dont think no ones going to spoon feed you everything

  10. #10
    Registered User
    Join Date
    May 2006
    Posts
    18
    that example was 2 advance if you can could u break it down (btw I'm only on lesson 3 of this sites help)

  11. #11
    Registered User
    Join Date
    May 2006
    Posts
    18
    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!

  12. #12
    Registered User
    Join Date
    May 2006
    Posts
    18
    but I do apresheate you help if you wanna give it (srry I'm a VERY bad speller)

  13. #13
    Registered User
    Join Date
    May 2006
    Posts
    34
    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.
    Last edited by unkownname; 05-09-2006 at 05:07 PM.

  14. #14
    Registered User
    Join Date
    May 2006
    Posts
    18
    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

  15. #15
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    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";
    }
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

Popular pages Recent additions subscribe to a feed