C Programming Interview Questions and Answers for Experienced - 1

Question: 1

What is the difference between getch() and getche()?

Both getch() and getche() are used to read single character there is very little difference

Both functions accept a character input value from the user.

When getch() is used, the key that was pressed will not appear on the screen. It is automatically captured and assigned to a variable.

While when getche() is used, the key that was pressed by the user appears on the screen and is assigned to a variable.

Question: 2

What is the syntax for ternary operators in C?

Ternary operator is same as if else control statement in C.

Syntax:

(Condition? true_value: false_vaue);

Question: 3

What is const pointer in C?

Const pointer is a pointer that can’t exchange the address of the variable that of pointing to.

Once const pointer is made to point one variable, we can’t change this pointer to point to any other variable.

This pointer is called const pointer.

 

Question: 4

What is wild pointer in C?

Uninitialized pointers are called as wild pointers in C which points to arbitrary (random) memory location.

This wild pointer may lead a program to behave wrongly or to crash.

Question: 5

Can a variable be both const and volatile?

Yes. The const modifier means that this code cannot change the value of the variable, but that does not mean that the value cannot be changed by means outside this code. If a variable is both const and volatile, the two modifiers can appear in either order.

 

Related Questions