C Programming Tricky Interview Questions

C Programming Tricky Questions and answers for freshers, beginners & people who are preparing for the interview or conducting the interview.  Go through the below questions & do let me know if you want to ask or share any of your interview session questions which can help other people.

How can you print any text within double quotes ” “ in c programming?

Answer:

#include<iostream>

int main()

{

std::cout << “\”interviewquestions.guru\””;

}

How you can print any text without using ; (semicolon) in c?

Answer:

#include <iostream>

int main()

{

if (std::cout << “tricky interview questions on c “)

{

}

// Or you can use below code instead of if use switch

switch (printf(“tricky questions on c “))

{

}

}

What is the use of a ‘\0’ character?

It is referred to as a terminating null character and is used primarily to show the end of a string value.

What is the difference between the = (equals) & == (double equals) symbol?

Answer: Double Equals is to compare & single equal is for assigning a value.

What is the output of the below program?

#define int char

main()

{

int i=77;

printf(“print sizeof(i)=%d”,sizeof(i));

}

Answer: print sizeof(i)=1(Since the #define replaces the string int by the macro char)

 

What will be the output if we call main in main?

main()  {  main();  }

Answer: you will get an Runtime error : Stack overflow

Choose the correct answer what would be output of below code.

#include <stdio.h>

int main()

{

float   a = 0.0;

float   b = 0.0;

int      c = 0;

a = (b/c) * 1000;

printf(“a = %f\n” );

}

  1. Will a be 0?
  2. Garbage value?
  3. Value like 0.000000?

Answer: C

How many times it will print interview question on c.

int main()

{

int x;

for(x=-1; x<=10; x++)

{

if(x < 5)

continue;

else

break;

printf(“Interview Question on c”);

 

}

return 0;

}

  1. Infinite Time
  2. 11 Times
  3. 0 Time
  4. 10 Times

Answer: C

Where in C program should we use keyword “Break”?

Answer: Break is used to control out of the block of code which is executing, we can use in loop statements or switch statements.

What are the modifiers available in C?

Answer: There are five modifiers in c.

  1. Short
  2. Long
  3. Signed
  4. Unsigned
  5. Long Long

Add a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!