Thread: New member

  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    18

    New member

    Hello guys I've just joined. I've had a look around and like what I see up to now, but couldn't find an introduction forum and believe it's proper etiquette to introduce oneself formally before participating so posted it under general discussions.

    With that out of the way a little about myself, I have just started to learn c, yesterday in fact so I have no prior experience within the language itself, but I have done a little Python before. I'm a Linux user and hope to eventually use what I learn here to help out within the Linux community but I know that's a long way away.

    So far my only learning recourse is the tutorials on this website, which are great but I'm struggling to understand the boolean operators (though admittedly I haven't searched these forums for a more in depth explanation as yet, but will be doing shortly).

    Also is there any other recourses you guys would recommend books etc I could pick up and work from?

    Thanks

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    By boolean, do you mean bitwise operators or logical operators?

  3. #3
    Registered User
    Join Date
    Jul 2013
    Posts
    18
    Quote Originally Posted by manasij7479 View Post
    By boolean, do you mean bitwise operators or logical operators?
    Sorry I meant logical operators, the example I saw and couldn't grasp properly was given like this:
    Code:
    A. !( 1 || 0 )         ANSWER: 0	 B. !( 1 || 1 && 0 )    ANSWER: 0 (AND is evaluated before OR) C. !( ( 1 || 0 ) && 0 )  ANSWER: 1 (Parenthesis are useful)
    What I don't understand is how each of them equates to true or false, I get 1 == true and 0 == false and understand the not, and, or operators but I don't know how they are determined from these. is that any clearer?

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Well it is like this

    Code:
    !( 1 || 0 )
    1 is true

    true || anything is true

    !(true) is false

    false is 0
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  5. #5
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Welcome to the forum! Be sure to read the forum guidelines if you haven't already.

    In my opinion, tutorials are good for practice and reference, but nothing beats a book for a good, thorough education. I'm hesitant to recommend a beginners book, as the one I learned from is very outdated and I'm not sure what is considered a good, modern book. Hopefully, someone else will be able to give you more direction.

    Also, feel free to start a thread if you have questions on boolean operators. I'm not sure if you're having trouble with the code syntax, implementation in code, or the underlying logic.

    Assuming the latter:

    - Zero equates to FALSE
    - Non-Zero equates to TRUE

    The truth tables for the basic logical operators:

    Code:
    /* Logic AND (&&) */
    
    FALSE and FALSE = FALSE
    FALSE and TRUE  = FALSE
    TRUE  and FALSE = FALSE
    TRUE  and TRUE  = TRUE
    
    
    /* Logic OR (||) */
    
    FALSE and FALSE = FALSE
    FALSE and TRUE  = TRUE
    TRUE  and FALSE = TRUE
    TRUE  and TRUE  = TRUE
    
    
    /* Logic NOT (!) */
    
    !FALSE = TRUE
    !TRUE  = FALSE

  6. #6
    Registered User
    Join Date
    Jul 2013
    Posts
    18
    Ok I think I get it now so
    Code:
    !( ( 1 || 0 ) && 0 )
    is true because the && function is evaluated first meaning that the || function is redundant which means the statement should be read as "not 0, or 1 which is true"? with the OR function removed from the argument? or am I reading into this wrong, sorry for the stupid questions just a little confused about this and if I don't undersatnd it now it will surely come back and bite me in the ass

  7. #7
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    It's good practice to take it one step at a time.

    Code:
    !( ( 1 || 0 ) && 0 )
    
    !( ( 1 ) && 0 )
    
    !( 0 )
    
    1
    Last edited by Matticus; 07-26-2013 at 10:25 AM.

  8. #8
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    because the && function is evaluated first meaning that the || function is redundant
    No - because of () || will be evaluated first
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  9. #9
    Registered User
    Join Date
    Jul 2013
    Posts
    18
    Quote Originally Posted by Matticus View Post
    Start with the inner-most parenthesis first, like math. Take it one step at a time.
    !( ( 1 || 0 ) && 0 )

    !( ( 1 ) && 0 )

    !( 0 )

    1
    [/code]

    I see that clears it up thanks you very much for your answer, it really helped.

    As for a book to learn from I've just ordered "c: How to program (6th edition)" based on the suggestions I found on here and should hopefully get that in a few days meanwhile I'll continue to go through the tutorials here and get myself primed thanks again to everyone who replied I really appreciate the help
    Last edited by japes789; 07-26-2013 at 10:34 AM. Reason: Typo

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Why C as a programming language, though? What is your rationale?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Registered User
    Join Date
    Jul 2013
    Posts
    18
    I chose C as i want to move into developing for Linux (kernel etc) i know that's a long way away and expect to be doing that anytime soon but this is mostly written in C and ASM (correct me if I'm wrong) and since I didn't want to start with ASM I'm starting with C first to get a solid background.

    What's wrong with C anyway lol so far I'm really enjoying it

  12. #12
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by japes789 View Post
    I chose C as i want to move into developing for Linux (kernel etc) i know that's a long way away and expect to be doing that anytime soon but this is mostly written in C and ASM (correct me if I'm wrong) and since I didn't want to start with ASM I'm starting with C first to get a solid background.
    Best of luck.
    You have a long way to go though, at least 2-3 years, if not more.
    What's wrong with C anyway lol so far I'm really enjoying it
    Who said anything is wrong?
    On the other hand, higher level languages are easier to learn, especially if that is your first language.

  13. #13
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    Who said anything is wrong?
    Can I buy whatever makes you so optimistic? I'm dreading this thread turning into yet another C++ v. C language war.

  14. #14
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by japes789 View Post
    I chose C as i want to move into developing for Linux (kernel etc) i know that's a long way away and expect to be doing that anytime soon but this is mostly written in C and ASM (correct me if I'm wrong) and since I didn't want to start with ASM I'm starting with C first to get a solid background.

    What's wrong with C anyway lol so far I'm really enjoying it
    I'm just checking that you're using the right tool for the job.
    In case you're planning on working in the kernel, then knock yourself out. You will need C and ASM and know low level stuff and hand optimize things.
    But consider that if you're ever going to move outside the kernel to, say, desktop apps, then you might want to invest in another higher level language.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  15. #15
    Registered User
    Join Date
    Jul 2013
    Posts
    18
    thanks for the reply i do want to get into kernel development mainly but asmanasij7479 said that's a long way away and I understand that I will maybe write a few little apps but these will mostly be cli as I don't really think a gui adds much functionality, what would you use for desktop apps? and what advantages would those have over C?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing member variable as default arg to member function
    By Memloop in forum C++ Programming
    Replies: 1
    Last Post: 09-08-2009, 06:49 PM
  2. member member function pointers
    By Bigbio2002 in forum C++ Programming
    Replies: 3
    Last Post: 12-04-2005, 05:14 PM
  3. Class member variables only readable by member functions?
    By _Elixia_ in forum C++ Programming
    Replies: 4
    Last Post: 10-10-2003, 03:52 PM
  4. private data member with public set member function
    By Mario in forum C++ Programming
    Replies: 2
    Last Post: 05-28-2002, 10:53 AM
  5. junior member/senior member/wtf/pictures
    By stupid_mutt in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 09-07-2001, 09:28 AM