FUNCTION IN C Programming language

A complex problem is often easier to solve by dividing it into several smaller parts(pieces), each of which can be solved by itself. Each sub-problem is more manageable than the original problem. This is called structured programming. These sub-problems which are easy to manage are made into Functions/Procedures/Modules in C. main() uses functions to solve the original problem. Thus A function is a block of code to perform a specific task. Every C program has at least one function main( ). Without main() function, there is technically no C program.

Advantages of Functions

The following are the advantages of using user defined functions:
1. Functions separate the concept (what is done?) from the implementation (how it is done?).
2. Functions make programs easier to understand thus improves the readability of program.
3. Functions can be called several times in the same program, allowing the code to be reused.
Functions in C.

There are 2 types of functions in C programming:
1. Library function
2. User defined function

C allows the use of both User-Defined Functions and Library Functions. Library Functions (e.g printf(), scanf(), getchar(), putchar(), abs(), ceil(), rand(), sqrt(), etc.) are usually grouped into specialized libraries.(e.g. <stdio.h>, <math.h> <string.h> and so on). Every Function takes some input(optional) and perform operations and give some output.
FUNCTION IN C Programming language FUNCTION IN C Programming language Reviewed by Unknown on 08:23 Rating: 5

No comments:

Powered by Blogger.