PDF- c interview question with answer -C Interview Question Answer - c question and answerr

Description

Sample c'questions and answers with explanation for interview

What will be output if you will compile and execute the following c'code

} (A) 320 (B) 1 (C) 64 (D) Compiler

Explanation: As we know size of int data type is two byte while char pointer can pointer one byte at time

Memory representation of int i=320

So char pointer ptr is pointing to only first byte as shown above figure

content of first byte is 01000000 and its decimal value is 64

How to represent char,

What will be output if you will compile and execute the following c'code

? #define x 5+2 void main(){ int i

} (A) 343 (B) 27 (C) 133 (D) Compiler

Explanation: As we know #define is token pasting preprocessor it only paste the value of micro constant in the program before the actual compilation start

If you will see intermediate file you will find: test

c 7: You can absorb #define only pastes the 5+2 in place of x in program

i=5+2*5+2*5+2 =5+10+10+2 =27 What is intermediate file and how to see intermediate file

What will be output if you will compile and execute the following c'code

-121 (D)

Compiler error

Explanation: As we know char data type shows cyclic properties i

if you will increase or decrease the char variables beyond its maximum or minimum value respectively it will repeat same value according to following cyclic order:

What will be output if you will compile and execute the following c'code