Operator

Question 1

The operation which is commutative but not associative is:

A
AND
B
OR
C
EX-OR
D
NAND
Question 1 Explanation: 
NAND and NOR operation follow commutativity but do not follow associativity.
Question 2

All digital circuits can be realized using only

A
Ex-OR gates
B
Multiplexers
C
Half adders
D
OR gates
E
Both B and C
Question 2 Explanation: 
NOR gate, NAND gate, Multiplexers and Half adders can also be used to realize all digital circuits.
Question 3
Consider the operator precedence and associativity rules for the integer arithmetic operators given in the table below.
Operator Precedence Associativity
+ Highest Left
High Right
Medium Right
/ Low Right
The value of the expression 3+1+5∗2 / 7+2−4−7−6 / 2 as per the above rules is __________
A
6
B
C
D
Question 3 Explanation: 
3+1+5∗2 / 7+2−4−7−6 / 2  ⇒ [ 3+1] +5∗2 / 7+2−4−7−6 / 2      [ + is highest precedence and its associativity is left ] => [4+5]∗2 / 7+2−4−7−6 / 2 [ + is highest precedence and its associativity is left ] => 9*2  / [7+2]−4−7−6 / 2 [ + is highest precedence and its associativity is left ] => 9*2  / 9 −4−7−6 / 2 => 9*2  / 9 −4−[7−6] / 2 [ - is high precedence and its associativity is Right ] => 9*2  / 9 −[4−1] / 2 [ - is high precedence and its associativity is Right ] => 9*2  / [9 −3] / 2 [ - is high precedence and its associativity is Right ] => 9*2  / 6 / 2 [ *  is next  precedence and its associativity is Right ] => 18/6/2 =>18/[6/2] [ only / operator and  its associativity is Right ] => 18 / 3 => 6
Question 4
Which of the following ‘C’ language arithmetic expressions has logical error?
A
-13 % -5 + 3;
B
4 / (-10 % -2) / 3;
C
3 / (-13 % -5) / 3;
D
-5 % 3 / 13;
Question 4 Explanation: 
→In the option B, -10%-2 gives remainder of “0” and then expression becomes 4/0/3.
→4/0 gives divide by zero error.
Question 5
Which of the following operators can be used if a portion of a given bit patterns needs to be copied to a new word, while the remainder of the new word is filled with 0’s?
A
Logical AND
B
Bitwise AND
C
Bitwise OR
D
Bitwise XOR
Question 5 Explanation: 
Bitwise AND is a binary operator that operates on two equal-length bit patterns. If both bits in the compared position of the bit patterns are 1, the bit in the resulting bit pattern is 1, otherwise 0.
Bitwise OR is also a binary operator that operates on two equal-length bit patterns, similar to bitwise AND. If both bits in the compared position of the bit patterns are 0, the bit in the resulting bit pattern is 0, otherwise 1.
Bitwise XOR also takes two equal-length bit patterns. If both bits in the compared position of the bit patterns are 0 or 1, the bit in the resulting bit pattern is 0, otherwise 1.
Question 6
Consider the statement,
“Either – 2 ≤ x ≤ – 1 or 1 ≤ x ≤ 2”.
The negation of this statement is
A
x < – 2 or 2 < x or – 1 < x < 1
B
x < – 2 or 2 < x
C
– 1 < x < 1
D
x ≤ – 2 or 2 < x or – 1 < x < 1
Question 7
main( )
{
   int x;
   x=3*4%5;
   printf(“x=%d”,x);
} 

The output is

A
x=2
B
x=2.3
C
x=5
D
x=1.9
Question 7 Explanation: 
‘*’ and ‘%’ operator have the same precedence but the associativity is from left to write. So x = 3*4%5 = 12%5 = 2.
Question 8

In C++ operator, << operator is called as

A
an insertion operator or put to operator
B
an extraction operator or get from operator
C
an insertion operator or get from operator
D
None of the given options
Question 8 Explanation: 
In C++ operator, << operator is called as an an insertion operator or put to operator.
Question 9

If x=5, y=2, then x^y equals (where, ^ is a bitwise XOR operator)

A
00000111
B
10000010
C
10100000
D
11001000
Question 9 Explanation: 
In XOR,
1 XOR 1 = 0
1 XOR 0 =1
0 XOR 0 = 0
0 XOR 1 = 1
So 5 in binary form is 00000101 and 2 in binary form is 00000010.
Hence 00000101 XOR 00000010 = 00000111.
Question 10

What is the output of the following C program

#include
int main()
{
int i=5;
printf("%d%d%d", i++, i ,++i);
return 0;
} 
A
7 6 6
B
6 7 8
C
6 7 7
D
5 6 7
Question 10 Explanation: 
int i=5;
printf("%d%d%d", i++, i ,++i);
In printf() the firstly the calculation is done from right to left and then printing is done from left to right.
So first ++i will increase the value of i by 1 and make it 6. Now the i will be read simply for second calculation.And now i++ will be calculated which will increment the value of i by 1 and make it 7, but since it is post increment so first 6 will be printed and then increment will be done and then for rest two 7 and 7 will be printed .Hence the output will be 6,7,7.
Question 11
In C language, x - = y + 1; means
A
x=x-y+1
B
x=-x-y-1
C
x=-x+y+1
D
x=x-y-1
Question 11 Explanation: 
In general, a-=b means a=a-b. So from this we can conclude that correct option is A.
Question 12
Consider following conditional statements if (m == 20 - 10 || n > 10). The order of execution of the following operations is
A. ==
B. -
C. ||
D. >
Choose the correct answer from the options given below:
A
D, B, A, C
B
B, D, C, A
C
B, D, A, C
D
A. B, D, C
There are 12 questions to complete.

Access quiz wise question and answers by becoming as a solutions adda PRO SUBSCRIBER with Ad-Free content

Register Now

If you have registered and made your payment please contact solutionsadda.in@gmail.com to get access