Interviews Questions, Algorithms, Aptitude, C Interview Program, C Theory Question, Aptitude Tricks, Test Series,

Wednesday 30 June 2021

Interview Hack#33 Answer


What will be the output of the following program?

  1. c questions
  2. c (null)
  3. (null) (null)
  4. (null) questions
  5. None of above

Correct answer (null) (null) & None of above


Run time Error or (null) (null) output varies with compiler


Explanation:

We cannot assign any string constant in the null pointer by strcpy function.

Tuesday 29 June 2021

Interview Hack#32 Answer

What will be the output of the following program?

  1. Address, Address, 3
  2. Address, 3, 3
  3. 3, 3, 3
  4. Compilation error
  5. None of these

Correct Answer 1)Address, Address, 3

Explanation:

Value of k is memory location defined for k.

Value of *k means the content of memory location which address k keeps.

**k will equal to 3.
As
**k = **(&j) = *(*&j) = *j = *(&i) = *&i = i = 3  

Monday 28 June 2021

Interview Hack#31

What will be the output of the following program?

  1. 320
  2. 3
  3. 64
  4. Compilation error
  5. None Of These

Correct answer 64

Explanation:
we know int is a 4-byte data byte while char is a 1-byte data byte. char pointer can keep the address one byte at a time.

The binary value of 320 is
00000000 00000000 00000001 01000000 (In 64 bit)

So ptr is pointing only the first 8 bit and the Decimal value is 64.

Sunday 27 June 2021

Interview Hack#30 Answer

 What will be output if you will execute the following c code?

  1. 0
  2. It will be difference of a and b
  3. It will be addition of a and b
  4. Compilation error

Answer: 4. Compilation error

Explanation:

Register variables are stored in the CPU. So it has not a memory address. Hence it is incorrect to write &a.

Saturday 26 June 2021

Interview Hack#29 Answer:

 The output of the following Code:

  1. 10 11 12 13 14
  2. 10 10 10 10 10
  3. 10
  4. 0 1 2 3 4 5
  5. Error

Answer:

2. 10 10 10 10 10

Explanation:

The default storage class of the local variable is auto. The scope of auto variables is blocked in which it has been declared. When program control goes out of the scope auto variables are dead. So variable I which has been declared inside for loop has scope within a loop and in each iteration, the variable is dead and re-initialized.