C Programming language

adplus-dvertising
What is a Function
Previous Home Next

Function in C

Functions are a powerful programming tool. A function is a block of code that performs a specific task. It has a name and it is reusable. It can be executed from as many different parts in a Program as required, it can also return a value to calling program. All executable code resides within a function. It takes in input, does something with it, then give the answer. A C program consists of one or more functions. A computer program cannot handle all the tasks by it self. It requests other program like entities called functions in C. We pass information to the function called arguments which specified when the function is called. A function either can return a value or returns nothing. Function is a subprogram that helps to reduce coding.

NOTE :If a program has only one function then it must be the main() function.

A simple example of Function in C

#include<stdio.h>
#include <conio.h>
int adition (int, int); //Function Declaration
int addition (int a, int b) //Function Definition
{
int r;
r=a + b;
return (r);
}
int main()
{
int z;
z= addion(10,3); //Function Call
printf ("The Result Is", %z);
return 0;
}

Output :The Result Is 13

Previous Home Next