C Functions ! What is a Function

Categories: C Programming language

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

Top Blogs
Introduction to Implementation of Queue using Linked List Published at:- Input and Output Functions in C Published at:- Importance of C Programming Language Published at:- How does C Programming Language Work Published at:- History of C Language : Introduction to C Programming Language Published at:- Benefits of C language over other programming languages Published at:- C Language Interview Question and Answers Published at:- Pointer declaration in C ,Address operator Published at:- C Program example: Input a number and print sum of its digits Published at:- What values are printed when we run following? Published at:- C Interview Questions And Answers Published at:- Learn C Programming language with example Published at:- C Memory Management ! Dynamic memory allocation Published at:- Structure in C: Introduction Published at:- Loops in C Published at:- Example of Function with no return type and no argument Published at:- Functions with arguments and no return values. Published at:- Functions with arguments and return values -C Examples Published at:- Functions that return multiple values -C Example Published at:- Types of Function in C ! Library Function in C ! User Defined Function In C ! Function Definition Published at:- C Functions ! What is a Function Published at:-
R4Rin Team
The content on R4Rin.com website is created by expert teams.