Programming Basics - C programming problems with solutions in objective type
Questions
16
An expression contains relational, assignment and arithmetic operators. If parenthesis are not specified, the order of evaluation of the operators would be:
Answer: Option [D]
17
Given two literals 0x001B and 033. What are these equal to?
Answer: Option [D]
Let us convert the given Hexadecimal number 0x001B to Decimal:
The first part is 0x160=0
The second part is 0x163+0x162+1x161+11x160 [Though B is equivalent to 11]
=27
So, 0+27=0
Now we convert the octal number 033 to decimal:
0x82+3x1+30
=27
⭐ Make GKSeries Your Preferred Source on Google
Add GKSeries as Preferred Source
18
What is the output of the following code segment(assuming sizeof(int) returns 4)?
int i=0x1 << sizeof(int)*8-1;
printf("\n%x",i);
i=i>>sizeof(int)*8-1;
printf("%d",i);
Answer: Option [B]

20
Which is the correct sequence statements that swaps values of two statements?
Answer: Option [B]
Let us test this with an example:
Let, a=20 and b=40. After swapping them a=40 and b=20
a=a+b; a=20+40=60;
b=a-b; 60-40=20;
a=a-b; 60-20=40;