1. ## 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. By boolean, do you mean bitwise operators or logical operators?

3. Originally Posted by manasij7479
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. Well it is like this

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

true || anything is true

!(true) is false

false is 0

5. 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. 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. It's good practice to take it one step at a time.

Code:
```!( ( 1 || 0 ) && 0 )

!( ( 1 ) && 0 )

!( 0 )

1```

8. because the && function is evaluated first meaning that the || function is redundant
No - because of () || will be evaluated first

9. Originally Posted by Matticus
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

10. Why C as a programming language, though? What is your rationale?

11. 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. Originally Posted by japes789
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. 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. Originally Posted by japes789
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.

15. 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?