C Programming Interview Questions and Answers - 5

Question: 21

What is the difference between exit() and return() in C?

exit() is a system call which terminates current process.

exit() is not an instruction of C language.

Whereas, return() is a C language instructions/statements and it returns from the current function (i.e. provides exit status to calling function and provides control back to the calling functions).

Question: 22

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

Both functions will accept a character input values from the user.

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

When using getche(), the key that was pressed by the user will appear on the screen, while at the same time being assigned to a variable.

Question: 23

What is the difference between top down approach and bottom up approach in programming languages?

Top down approach and bottom up approach are involved in software development. These approaches are not involved in program execution.

Structure/procedure oriented programming languages like C programming language follows top down approach. Whereas object oriented programming languages like C++ and Java programming language follows bottom up approach.

Top down approach begins with high level design and ends with low level design or development. Whereas, bottom up approach begins with low level design or development and ends with high level design.

In top down approach, main() function is written first and all sub functions are called from main functions. Then sub functions are written based on the requirements. Whereas, in bottom up approach, code is developed for modules and then these modules are integrated with main() function.

Nowadays, both approaches are combined together and followed in modern software design.

Question: 24

What is the difference between calloc and malloc?

calloc and malloc are used for dynamic memory allocation. calloc initializes the memory locations to zero by default but malloc memory contains garbage values.

Question: 25

What is a newline escape sequence?

A newline escape sequence is represented by the character.

This is used to insert a new line when displaying data in the output screen.

More spaces can be added by inserting more characters.

For example, would insert two spaces. A newline escape sequence can be placed before the actual output expression or after.

Related Questions