Join our Telegram Channel

Programming Basics - C programming problems with solutions in objective type

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

Answer: Option [D]
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

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]


So, 0+27=0

Now we convert the octal number 033 to decimal:





18 What is the output of the following code segment(assuming sizeof(int) returns 4)?

	int i=0x1 << sizeof(int)*8-1;
A 0x8000000-1
B 80000000-1
C -1 0x0000000
D -1 0000000

Answer: Option [B]

mcq on c programming c basic 03

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

Answer: Option [A]
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

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;


GkSeries apsc prelims 2023 test series

Today's Top Current Affairs

Current Affairs MCQs

State-wise Current Affairs

General Knowledge

Month-wise Current Affairs 2023

Category-wise Current Affairs

Jobs by Qualification

Free Mock Test