C++ knowledge test
English
Advanced
Do you know everything about C++? Sure? Then this test is for you!
Description
32
Questions
30 sec
Per question
5:36
Average time
4.0
Contest Score
4.5
Community Rating
11
Participants
16 comments
Dandy Otter judge
This test may have a higher chance of receiving a reward. Nominated for:

Educational explanations. 👍 Explanations cover why the correct answers are correct and why the wrong answers are wrong (when appropriate). E.g.: #q1, #q2, #q3
Stout Shrimp
Explanation in the question about:
true||false&&false

states that first the operation && will be performed and that's not true. In C++ operands || and && have the same priority and are left associative, also, they are short-circuited operands, then:
true||false&&false

will be interpreted as:
true||(false&&false)

and true will be evaluated first, resulting in a trivial true and then the right of the or operator (expression at the right of ||) won't be evaluated.
Small Lizard author
Proofs of my opinion:
1. Wikipedia link: https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Operator_precedence (precedence of && is higher than of ||)
2. I ran this code in an online compiler and the result is true: https://ideone.com/IUkk9z (output is 1 which means true, regardless of the order in which the operations are written)
Calm Wolf
Small Lizard Interesting problem: if it's 'true||false&&false', then it evaluates to be true; when it's 'false&&false||true', it yields us 0. If && operator had a higher precedence than ||, then the change of order wouldn't change a result, however it did.
Stout Shrimp
|| operator has higher precedence than &&
https://en.cppreference.com/w/cpp/language/operator_precedence

That's why:
true||false&&false

becomes:
true||(false&&false)

What I states is that || operator is evaluated first, so the left of the || is evaluated first wich is trivially true and this operator is short-circuited so (false&&false) is never evaluated.

In explanation says that (false&&false) is evaluated first.
Small Lizard author
Calm Wolf You said "when it's 'false&&false||true', it yields us 0".
No, "(false&&false||true) = 1" as written in my link from previous comment: https://ideone.com/IUkk9z
Stout Shrimp
Small Lizard I didn't say it's not true. I said it's true, what is wrong is the operational order.

Run this:
https://ideone.com/RlhdRP

And you'll see the left operand of || will be evaluated first and the right operand won't be evaluated :)
Smart Antelope
"Choose extra word:" is ambiguous of a question. What's better is "Select the word that isn't a reserved keyword in C++:"
Small Lizard author
Quiz is about C++. So this question is also about C++ and nothing except it. My answer is the only word (from the options) that does not mean anything in C++. There is no another option in my question that can be extra in terms of C++.
Smart Antelope
Small Lizard Yeah I understood what you mean like 3 seconds after I read the question. This took up precious time seeing as youve put a time limit of 15sec. I feel it might be a bit short, especially when I tried to read questions with code in them. 15 seconds wasnt enough.
Smart Antelope
Small Lizard Sorry 30 seconds.
Smart Antelope
Small Lizard I mean its a good quiz for advanced so I'll give you that
Giant Kitten
Outstanding quiz. I really enjoyed it. Just to point out 30 seconds is a really short time given the nature of the quiz.
I see it has been raised before, I also have an issue with choose extra word questions; it's abit vague. Maybe choose one that is different or something like that may be better. Well done. Good luck:)👍
Take the quiz to leave a comment