  8000+ STATIC GK MCQs for SSC/ Railway/ PSC
1000 POLITICAL SCIENCE MCQS | EBook
Get 22 nos. GK EBooks | Combo Pack
Current Affairs Monthly Magazine -Subscribe Now!
1000 BIOLOGY MCQS AND ANSWERS | EBook
1000 ECONOMICS MCQS FOR EXAMS | EBook
Mughal Empire MCQs | EBook
ECONOMIC GEOGRAPHY MCQs | EBook
350 MCQs ON INDIAN CONSTITUTION | EBook

# 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:
A assignment, arithmetic, relational
B relational, assignment, arithmetic
C assignment, relational, arithmetic
D arithmetic, relational, assignment

17 Given two literals 0x001B and 033. What are these equal to?
A 21 and 23
B 27 and 33
C 33 and 33
D 27 and 27

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

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);
```
A 0x8000000-1
B 80000000-1
C -1 0x0000000
D -1 0000000 19 Which is the valid statement in C?
A #define half(x)((x)/2.0)
B #define STREQ(s1,s2)(strcmp((s1),(s2))==0);
C #define MAX=5
D #define INTEREST 5, LOAN 5000

20 Which is the correct sequence statements that swaps values of two statements?
A a=a+b; a=a-b; b=a-b;
B a=a+b, b=a-b; a=a-b;
C a=a-b; a=a+b; b=b-a;
D None of these

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;