Test Series - cpp

Test Number 34/102

Q: What is a binary operator?
A. Operator that performs its action on a single operand
B. Operator that performs its action on two operand
C. Operator that performs its action on three operand
D. Operator that performs its action on any number of operands
Solution: As the word binary itself means 2 therefore a binary operator operates on two operands.
Q: Which is the correct example of a binary operator?
A. ++
B. 
C. Dereferencing operator(*)
D. +
Solution: +(adding two operands) requires two operands whereas ++(increases value by 1), –(decreases value by 1) and *(dereferencing operator used for accessing value of pointers) requires only one operand.
Q: Which is the correct example of a unary operator?
A. &
B. ==
C. 
D. /
Solution: &, == and / requires two operands whereas — requires only one operand, in general, it decreases the value of operand by 1.
Q: Which is called ternary operator?
A. ?:
B. &&
C. |||
D. ===
Solution: ?: is called ternary operator because it separates three expressions. exp1 ? exp2 : exp3.
Q: Which is the correct statement about operator overloading?
A. Only arithmetic operators can be overloaded
B. Only non-arithmetic operators can be overloaded
C. Precedence of operators are changed after overlaoding
D. Associativity and precedence of operators does not change
Solution: Both arithmetic and non-arithmetic operators can be overloaded. The precedence and associativity of operators remains the same after and before operator overloading.
Q: Pick the incorrect statements out of the following.
A. Operator overloading does not disturbs the precedence of operators
B. Arity of operators can be changed using operator overloading
C. No new operators can be created
D. All of the mentioned
Solution: Arity means a number of operands an operator requires to perform its action and operator overloading does not changes the arity of any operator.
Q: Which header file is used to declare the complex number?
A. complexnum
B. complex
C. complex number
D. complexarg
Solution:  header file is used for declaring a complex number in C++.
Q: How to declare the complex number?
A. (3, 4)
B. complex(3, 4)
C. (3, 4i)
D. (3, 4g)
Solution: We can declare the complex number by using complex(3,4) where 3 is a real number and 4 is imaginary part.
Q: How many real types are there in complex numbers?
A. 1
B. 2
C. 3
D. 4
Solution: There are three real types in complex numbers. They are float complex, double complex, long double complex.
Q: Which of the following is not a function of complex values?
A. real
B. imag
C. norm
D. cartesian
Solution: Real is used for returning real part, imag for imaginary part and norm for calculating norm of a complex number. There is no such function Cartesian in complex header file.

You Have Score    /10