nob question True or false

This is a discussion on nob question True or false within the C Programming forums, part of the General Programming Boards category; i dont understand the logic behind this can someone explain this to me int a,b,c,d,e,f a = (6 < 3); ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    62

    nob question True or false

    i dont understand the logic behind this can someone explain this to me


    int a,b,c,d,e,f

    a = (6 < 3); a= 0; (false)

    b = ! a; b=Not(0);
    b=1 why is it 1
    c = a && b;
    d = (a == !b) && ('t'>'A');
    e = d || c && !a;
    f = c && d || e;
    Last edited by joker_tony; 03-08-2008 at 01:12 PM.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Is this a typo:
    Code:
    d = (a == !b) %% ('t'>'A');
    In C, 'true' is 1 and 'false' is zero, but "anything not zero" is accepted as true in a condition (e.g. in if/while conditions).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. the chess project
    By Hussain Hani in forum Projects and Job Recruitment
    Replies: 8
    Last Post: 05-28-2007, 03:33 AM
  2. [Help] Tutorial : If Statements
    By hackerkts in forum C++ Programming
    Replies: 8
    Last Post: 02-12-2006, 04:27 PM
  3. 1 or 0 == true or false?
    By Discolemonade in forum C++ Programming
    Replies: 4
    Last Post: 08-14-2005, 05:08 PM
  4. Simple thread object model (my first post)
    By Codeplug in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2004, 11:34 PM
  5. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 07:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21