Which Function Comes as an Integral Component of C Program?

Question: Is Function an Integral Component of Every C Program?

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.

advertisement
advertisement
If you wish to look at all C Tutorials, go to C Tutorials.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.