Function A Self Contained Block In C 0 1924

Function is a small program which takes some input and gives us some output.

Function allows a large program to be broken down into a number of smaller self contained components, each of which has a definite purpose. It avoids rewriting the code over & over.

Breaking down of logic into separate functions make the entire process of writing & debugging easier.

Function is a self contained block of statements that is used to perform some task. A function is assigned some work once and can be called upon for the task any number of times. Every C program uses some functions, the commonly used functions are printf, scanf, main,etc.

Functions can be library functions or user defined functions. Library functions are those functions which come along with the compiler and are present in the disk.

The user defined functions are those which the programmer makes by himself to make his program easier to debug, trace. printf ( ), scanf( ), exit( ), pow( ) are library functions.

Every library function has a header file. There are a total of 15 header files in C. main( ) is a user defined function.

Every program must have a main function. The main function is used to mark the beginning of the execution. It is possible to code any program using only the main program but this leads to many problems.

It becomes too large and complex thus difficult to trace, debug and test. But if the same program is broken into small modulus coded independently and then combined into a single unit then these problems can be solved easily. These modulus are called as functions.

Thus a function can be defined as a small program which takes some input and gives us some output.

 

 

Previous ArticleNext Article
Indian Mirchi will serve you taste in Indian news, general knowledge and information. Hope you like the story I write here and expect your points of discussion to improve them and give the best chili test out of the story. I will write tutorials also that helps students. In case you are looking for any specific information then share me in the comment.

Send this to a friend