What is purpose of return type in main function in C?

What is the purpose of “return 0” in main () function in C and why not to prefer using void like “void main()”? Here’s the main function declaration example with return 0, Question: What is purpose of return type in main() function in C? For example, we have written “int main ()”, means, it returns […]

How to print hello world without semi colon in C?

We can print hello world without using semi colon using if condition in C program as below. Elaborating, Intent of the question is that we can print values on console screen using printf function as shown in below program. Output: hello world But, how you can print hello world without semi colon? Meaning, we don’t […]

Notes on Function Pointer in C – Uses Callback Example

Complete notes on function pointer in C or say pointer to function in C programming – Example of declaration, typedef, real time uses as callback function with program examples. Real life use of call back function is extracted from one of the real product scenario as a pseudo code. Function pointer in C Function pointer […]

Interview questions on malloc function in C with 3 example scenarios

malloc function in c programming examples interview question based on scenarios – Write programs for following scenarios: Q-1: Allocate memory dynamically using malloc() function for 1 integer, store value 10 and read it.Q-2: Create memory block for 10 integers and store and read numbers from 0-9.Q-3: Copy String from an array char[] =”Hello World” to […]

Explain malloc calloc realloc free in c with example

Answer includes malloc calloc realloc free in c with example Answer: Dynamic memory allocation in C language programming is the process of memory allocation from heap memory at run time. In other word, when memory is allocated from heap during program execution is called dynamic memory allocation. Also note that, in dynamic memory allocation, memory […]

do while Vs while loop in C Programing?

Answer: Difference between do while and while loop in C programming: do…while loop guaranteed to execute at least one time whereas while loop does not. All statements within do…while loop get executed first and then while condition is checked. Hence, it executes at least one time. In the below example, the string “interviewsansar.com” will be […]

Include guards – why to write in header files – C, C++

Answer: The include guards in header file in C, C++ is used to avoid compiler error i.e. redefinition of function, variable or class. The #include guards (also know as header guards) technique are heavily used in the C and C++ projects that have multiple headers and source files. In fact, the include guards prevent inclusion […]

Scroll to top