JOIN ADRE 2.0 Telegram Group

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

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]

=27

So, 0+27=0

Now we convert the octal number 033 to decimal:

0x82+3x1+30

=27

Advertisement
APSC CCE PRELIMS Mock Test - 1 Start Test
APSC CCE PRELIMS Mock Test - 2 Start Test

DOWNLOAD CURRENT AFFAIRS PDF FROM APP

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

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;

APSC PRELIMS FULL LENGTH MOCK TEST

Take Mock Tests

Government Schemes Mock Test Start Test!
Political Science Mock Test – 42 Start Test
History Test – 190 Start Test
Quantitative Aptitude Test Start Test!
Trigonometry - Mock Test Start Test!
Data Interpretation - Mock Test Start Test!
General Awareness - Mock Test Start Test!
Reasoning Ability - Mock Test Start Test!
Englist(Antonyms) Mock Test 1 Start Test!
Quantitative Aptitude (Percentage) Mock Test Start Test!
Economy Mock Test 1 Unlock Test!
Books & Authors - Test 2 Unlock Test!

Chapters

apsc cce prelims 2024 test series