Shocking - only 15 out of 20, surely some mistake....
1. Which of the following is an example of compounded assignment statement?
a = 5
a += 5
a = b = c
a = b Ans : 2
Since K&R doesn't actually define the term "compounded assignment", one is left guessing as to what the hell they're talking about. Their answer is correctly called an assignment operator.
4. The operator / can be applied to
All of these Ans : 2
Apparently, we're supposed to use something other than / for division of ints and doubles :icon_rolleyes:
9. Which of the following operator has the highest precedence?
+ Ans : 4
Since => isn't actually an operator, I toyed with the idea that it was a typo and it really meant ->
Their "answer" comes in from left field and complete levels anyone with any competence in C.
16. What will be the output of the expression 11 ^ 5?
None of these Ans : 2
Yet more trouble for anyone who actually knows the answer rather than some chimp guessing away.
Somewhat strangely, it is the "right" answer if you assume that the "11" is in binary, and the "5" is decimal, but that sure is a contrived way of screwing things up. It certainly wouldn't compile as an expression.
20. p++ executes faster than p+1 because
p uses registers
p++ is a single instruction
++ is faster than +
None of these Ans : 2
I was bound to get this one wrong because the quizmaster has obviously got some weird implementation specific view of how the universe works. Nowhere in the standard does it state that ++ should be a single instruction, because there is no need for such a detail. Indeed, the very notion that ++ may be faster than +1 is flawed, since any half-decent compiler will render the same code for them anyway.
Yes, that is one of the poorer online C tests I've seen in a while. You'd do well to avoid it.
"IndiaStudyCenter.com makes no warranty that the contents of the Site are free from infection by viruses or anything else which has contaminating or destructive properties."
ROFLMAO - having read the questions in the quiz, that's not all that can be considered "harmful" :icon_biggrin:
public class GrossmontBank
//class variables (global - accessible throughout this class)
//scanner object to be used throughout
private static Scanner input = new Scanner(System.in);