Answer: Before we proceed to answer this, let’s look at the design, in its simplest form, of a C program,
/* * sim_c_prog.c -- program shows even simplest C program requires function * main() */ void main(void) { /* Nothing happens here! */ }
When compile and run the program on Linux system, nothing happens! Here, ‘main()’ function takes no arguments nor does it return any value and further, it performs nothing. Hence, no headers are required! So why this is the simplest C Program!
Remember to specify ‘void’ keyword in parenthesis following the function name if any C function doesn’t take any arguments, and when any C function doesn’t return any value, specify type of function as ‘void’. Headers contain declarations for ANSI C library functions. In the above program, we haven’t used any C library function, for example, printf(), scanf() etc., so we didn’t include any header.
So, we, here, observed, function is an integral component of every C Program! Basically, according to C’s philosophy, functions are used to organize larger programs and allow them to be used across other programs too. Therefore, functions enable us to avoid redundancy of code!
Sanfoundry Global Education & Learning Series – 1000 C Tutorials.
- Watch Advanced C Programming Videos
- Practice Computer Science MCQs
- Practice BCA MCQs
- Check C Books
- Apply for C Internship