Question: 6 -
What is the name of | operator?
-
and
-
modulus
-
or
-
sizeof
Answer:
or
Solution:
| operator is used to find the ‘or’ of given values.
| operator is used to find the ‘or’ of given values.
Question: 7 -
What will be the output of the following C++ code?#include <iostream>
using namespace std;
int main() {
int a = 0;
int b = 10;
a = 2;
b = 7;
if (a && b) {
cout << "true: " << endl;
}
else
{
cout << "false: " << endl;
}
return 0;
}
-
error
-
10
-
false
-
true
Answer:
false
Solution:
&& is called as Logical AND operator, if there is no zero in the operand means, it will be true otherwise false.
&& is called as Logical AND operator, if there is no zero in the operand means, it will be true otherwise false.
Question: 8 -
What is the associativity of add(+); ?
-
right to left
-
left to right
-
right to left & left to right
-
top to bottom
Answer:
left to right
Solution:
left to right is the associativity of add(+);.
left to right is the associativity of add(+);.
Question: 9 -
What will be the output of the following C++ code?#include <iostream>
using namespace std;
int main() {
int a, b, c;
a = 2;
b = 7;
c = (a > b) ? a : b;
cout << "c: " << c;
return 0;
}
-
2
-
9
-
14
-
7
Answer:
7
Solution:
We are using the ternary operator to evaluate this expression. It will return first option, if first condition is true otherwise it will return second
We are using the ternary operator to evaluate this expression. It will return first option, if first condition is true otherwise it will return second
Question: 10 -
Which operator is having the highest precedence in c++?
-
Scope resolution operator
-
array subscript
-
static_cast
-
dynamic_cast
Answer:
Scope resolution operator
Solution:
Scope resolution operator is having the highest precedence in c++.
Scope resolution operator is having the highest precedence in c++.