C Programming and Problem Solving Questions and Answers 181 to 190

C Programming and Problem Solving

Questions 181 to 190



181.
Which of the following is not a character constant?
(a)
‘\60’
(b)
‘\x24’
(c)
‘sum’
(d)
‘A’
(e)
‘\012’.
182.
In the statement # define, the symbol # must commence from
(a)
Any where in any line
(b)
First character of that line
(c)
Before main() function but after # include statement always
(d)
Before main() function but before # include statement always
(e)
Any where out side of main() always.
183.
How many number of tokens are there in the following statement, provided ‘value’ is
an integer variable?
if(  value == 21 )
(a)
3
(b)
4
(c)
5
(d)
6
(e)
7.
184.
What is the final value of ‘a’, if the following code is executed with initial value of ‘a’ as 10?
int  b=10, c=20, d=-10;
a = 20-c >  b+d;
a--;
(a)
9
(b)
0
(c)
10
(d)
1
(e)
-1.
185.
Arrange the operators ‘&’,  ‘&&’,  ‘|’, ‘||’, ‘^’ based on priority.
(a)
&     ^      |      &&   ||
(b)
&     &&   ^      |      ||
(c)
&     &&   |      ^      ||
(d)
&     &&   |      ||      ^
(e)
&     |       ^      &&   ||.
186.
The number of binary bitwise operators are
(a)
2
(b)
3
(c)
4
(d)
5
(e)
6.
187.
From the following, which expression will correctly swap two integers x, y without using a temporary variable?
(a)
(x^=y), ( y^=x)
(b)
 (x^=y), ( y^=x), (x^=y)
(c)
x^=(y^=x)
(d)
(x=y), (y=x)
(e)
(x=y), (y=x), (x=y).
188.
Pick the fully correct and portable method to obtain the most significant byte of an unsigned integer x.
(a)
x >>24
(b)
x || 0xFF00
(c)
x && 0xFF00
(d)
x >> (CHAR_BIT * (sizeof(int)-3))
(e)
x >> (CHAR_BIT * (sizeof(int)-1)).
189.
What will be the value of ‘i’ after the following code is executed, provided 1 as the initial value of ‘i’?
i = (i <<= i%2 );
(a)
Syntax Error
(b)
Logical error
(c)
2
(d)
1
(e)
0.
190.
What is the final output for the below code?
int  i = 020;
int  j = 025;
int  k = 50;
k=i + j;
printf( “%d”, k );
(a)
45
(b)
045
(c)
50
(d)
037
(e)
37.

Answers


181.
Answer : (c)
Reason  :       As ‘sum’ is not a single character constant but a string constant and should be there in double quotes.
182.
Answer : (b)
Reason  :       According to the syntax rules, # should be the first character of a line or the line already having # define there in the line
183.
Answer : (d)
Reason  :       The tokens are if, (, value, ==, 21, ) and hence six tokens.
184.
Answer : (e)
Reason  :       Because 20-c > b+d is false which is 0 in C and zero is assigned to a and then it is decremented by one.
185.
Answer : (a)
Reason  :       According to the Priority and precedence of the operators.
186.
Answer : (d)
Reason  :       They are &, |, ^, <<, >>
187.
Answer : (b)
Reason  :       This is same as writing x ^= y ^= x ^=y;
188.
Answer : (e)
Reason  :       CHAR_BIT gives the number of bits in a byte. The most significant byte starts from 8th bit position if the run time system allocates 2 bytes of memory for the integer variable. And starts from 24th bit position if the run time system allocates 4 bytes of memory for the integer variable
189.
Answer : (c)
Reason  :       Here i%2 is 1 and i<< 1 causes the bits of I to be shifted one position towards right and causes I to become 2 which is again assigned to I in this statement.
190.
Answer : (e)
Reason  :       This is decimal equivalent of i, j are 16, 21 respectively which are added.



<< Prev 1...  2...  3...  4...  5...  6...  7...  8...  9...  10...  11... 12...  13...  14...  15...  16...  17...  18...  19...  20...  21...  22...  23...  24...  25...  26...  27...  28...  29...  30...  31...  32...  33...  34...  35...  36...  Next >>


No comments :

What you think about these Questions and Answers ? Let me know in comments.

Post a Comment