We have seen that C supports the use of predefined library functions which are used to carry out a large number of commonly occurring tasks e.g., printf, scanf etc. However, C also allows programmers to define their own functions. The use of programmer – defined functions permits a large program to be broken down into a number of smaller, self – contained units. In other words, a C program can be modularized via the sensible use of programmer defined functions. In general, modular programs are far easier to define, write, debug and use. Furthermore, proper modularization allows other people to grasp the logical structure of a program.
A function is a self – contained program segment that carries out some specific, well – defined task. Every C program consists of one or more functions. One of these functions must be called main. Main is a specially recognized function in C. Every program must have a main function to indicate where the program has to begin its execution. Execution of the program always begins by carrying out the instructions contained in main. Note that if a program contains multiple functions then their definitions may appear in any order. One function definition cannot be embedded within another. The same function can be accessed from several different places within a program. Once the functions carried out its intended actions, control is returned to the point from which the functions was accessed. Generally speaking, a functions processes information passed to it from the calling portion of the program, and returns a single value. Some functions, however, accept information but do not return anything e.g., printf does not return any value but scanf returns multiple values.
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc