C Programming and Problem Solving
Questions 181 to 190
181.
|
Which
of the following is not a
character constant?
|
||||||||||
In the
statement # define, the symbol # must commence from
|
|||||||||||
How
many number of tokens are there in the following statement, provided ‘value’
is
an
integer variable?
if( value == 21 )
|
|||||||||||
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--;
|
|||||||||||
Arrange
the operators ‘&’,
‘&&’, ‘|’, ‘||’, ‘^’
based on priority.
|
|||||||||||
The
number of binary bitwise operators are
|
|||||||||||
From
the following, which expression will correctly swap two integers x, y without
using a temporary variable?
|
|||||||||||
Pick
the fully correct and portable method to obtain the most significant byte of
an unsigned integer x.
|
|||||||||||
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 );
|
|||||||||||
What is
the final output for the below code?
int i = 020;
int j = 025;
int k = 50;
k=i + j;
printf(
“%d”, k );
|
Answers
181.
|
Answer : (c)
Reason : As
‘sum’ is not a single character constant but a string constant and should be
there in double quotes.
|
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
|
|
Answer : (d)
Reason : The
tokens are if, (, value, ==, 21, ) and hence six tokens.
|
|
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.
|
|
Answer : (a)
Reason : According
to the Priority and precedence of the operators.
|
|
Answer : (d)
Reason : They
are &, |, ^, <<, >>
|
|
Answer : (b)
Reason : This
is same as writing x ^= y ^= x ^=y;
|
|
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
|
|
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.
|
|
Answer : (e)
Reason : This
is decimal equivalent of i, j are 16, 21 respectively which are added.
|
No comments :
Post a Comment