# Thread: Hello everyone, super noob!

1. ## Hello everyone, super noob!

Hey all, this is my first post on the forum, so let me know if i am in the wrong spot. I am trying to teach myself C++ and have just started going through the tutorial here on the site, this is my first attempt at any type of programming. I have the Dev-C++ compiler which is working great, now I have a question, I just went through the 2nd tutorial on "if statements" and took the quiz thing here's the question

1. Which of the following is true?
A. 1
B. 66
C. .1
D. -1
E. All of the above

now of course A is true, and that's what i went with, but apparently the answer is all of them? can anyone clear this up for me? i understand that each value has the ability to return a true statement, is that what the question is meaning?

and also, in this line:

!( 1 || 1 && 0 )

when there's no parenthessis the 1 && 0 is looked at first equaling false, then 1 || 0 equaling true then !(1) equaling false, am i going about that right?

2. In C++, 0 evaluates to false. Since none of the options are 0, they must all evaluate to true.

when there's no parenthessis the 1 && 0 is looked at first equaling false, then 1 || 0 equaling true then !(1) equaling false, am i going about that right?
Yes.

3. True and false are BOOL data types. Apparently, it seems to be that 0 is false and everything else is true.
BOOL data type actually returns a bit (i think so) and the true and false "checking" should be something like this:
Code:
```if(intgr==0){
//false
}
else{
//true
}```
You are right about those && and || things...

4. awesome! thanks for the fast replies

i was thinking that it's either 1 or 0, true or false, not true unless proven false, thanks for clearing that up!

question 2

1. What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run?
A. 10
B. 9
C. 0
D. 1

now when this is run it stops at 9, 0-9 is 10 equations BUT the final value is 9 i'm confused :S

5. Now my test:
Code:
```if(1 && 0 == 0 && 1)
{
//Nothing especial
}```
Say if it enters the if block or not.

6. Originally Posted by TiznaraN
awesome! thanks for the fast replies

i was thinking that it's either 1 or 0, true or false, not true unless proven false, thanks for clearing that up!

question 2

1. What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run?
A. 10
B. 9
C. 0
D. 1

now when this is run it stops at 9, 0-9 is 10 equations BUT the final value is 9 i'm confused :S
It's quite easy actually.

Int = 0
Loop finishes 1st time, Int is now 1.
Loop finishes 2nd time, Int is now 2.
Loop finishes 3rd time, Int is now 3.
Loop finishes 4th time, Int is now 4.
Loop finishes 5th time, Int is now 5.
Loop finishes 6th time, Int is now 6.
Loop finishes 7th time, Int is now 7.
Loop finishes 8th time, Int is now 8.
Loop finishes 9th time, Int is now 9.
and stops looping because int is now = 9 and not < 9...

7. Originally Posted by siavoshkc
Now my test:
Code:
```if(1 && 0 == 0 && 1)
{
//Nothing especial
}```
Say if it enters the if block or not.
I could say it easily if I would open my compiler, copy it there and press COMPILE.

8. BUT the final value is 9
No. It will be ten. Try this:
Code:
```int x;
for(x=0; x<10; x++) {}
cout << x;```
I could say it easily if I would open my compiler, copy it there and press COMPILE.
The original question could be answered in that way too, smart boy.

9. siavoshkc

if(1 && 0 == 0 && 1)
{
//Nothing especial
}

0 = 0 is true so it would not block and would keep repeating?

but as far as the quiz qustion, the answer is 10, and the final value of that statement is 9, 0-9 10 equations, but value of 9 right?

10. 0 or "zero" is a non-number, thus C++ compilers regards it as false.

The statement

Code:
```bool b = true;
bool c = false;

cout << b << endl
<< c << endl;```
Would print 1 and 0. 1 is true. 0 is false

11. 0 = 0 is true so it would not block and would keep repeating?
The if statement and the following code between braces, and following else if, are all together called "if block", a code block.

Would print 1 and 0. 1 is true. 0 is false
It is just because cout is designed that way.

12. ok so yes then if would enter the block, i thought i just read somewhere that when it doesn't enter into the if execution it's called a "block"

13. ok so i'm kinda pumped, someone give me a BEGGINER! quiz or something to test what i think i've learned so far or does anyone know of anywhere i can go to test my knowledge? newbie projects?

14. Originally Posted by TiznaraN
ok so i'm kinda pumped, someone give me a BEGGINER! quiz or something to test what i think i've learned so far or does anyone know of anywhere i can go to test my knowledge? newbie projects?
Just keep learning, that's all you have to do. You won't be able to make anything mind provoking until you learn a little more.

15. But if you like, solve this, enters or not?
Code:
```int a = 41;
int b = 20;
if( (a || b)^ !(a- b) ^ ( (41 - a)  &&  !(a || false) && (b -  20 || true) )  )
{
//Nothing especial
}```