Offers
Thanks for visiting www.technoexam.com. Stay connected with us for more latest programming updates...

You are here : Home >> Tutorials >> C

Go
Basic C Tutorial

Contents
What is C ?
History
Structure of C Program
Variables & Keywords
Constants
Data Types
Operators
Operators Precedence
Conditional Statements
if Statement
if else Statement
nested if else
switch case
Looping Statements
While loop
Do While loop
For loop
Break
Continue
Goto
Functions
Passing Value
Returning Value
Passing & Returning
Recursion
Storage Class
Array
Structure
Pointer
Union
Strings
Header File
Programs Library
Projects Library
Learn More+

Contact Us

+91-8806583119

Functions in C

The function is a self contained block of statements which performs a coherent task of a same kind.

C program does not execute the functions directly. It is required to invoke or call that functions. When a function is called in a program then program control goes to the function body. Then, it executes the statements which are involved in a function body. Therefore, it is possible to call fuction whenever we want to process that functions statements.

Types of Functions

There are 2(two) types of functions as:

1. Built in Functions
2. User Defined Functions


1. Built in Functions :

These functions are also called as 'library functions'. These functions are provided by system. These functions are stored in library files. e.g.

2. User Defined Functions :

The functions which are created by user for program are known as 'User defined functions'.

Syntax:

void main()
{
	// Function prototype
	<return_type><function_name>([<argu_list>]);
	
	// Function Call
	<function_name>([<arguments>]);
}
// Function definition
<return_type><function_name>([<argu_list>])
{
	<function_body>;
}

Program :

// Program to demonstrate function
#include <stdio.h>
#include <conio.h>

void add()
{
	int a, b, c;
	clrscr();
	printf("\n Enter Any 2 Numbers : ");
	scanf("%d %d",&a,&b);
	c = a + b;
	printf("\n Addition is : %d",c);
}
int main(void)
{
	void add();
	add();
	getch();
	return 0;
}

Output :

 Enter Any 2 Numbers : 23 6
 Addition is : 29_

Advantages of Using Functions:

Download PDF
Published on: 12th Nov 2010, Last Updated on: 18th Dec 2014

Mr. Dinesh Kudache
AUTHOR: Mr. Dinesh Kudache

Mr. Dinesh is the Founder and CEO of technoexam.com. He had 6+ years experience in Application Programming, System Programming, Web Design and Development, Google Expertise. He had written 5000+ various articles on programming. Browse more articles by this author.

Link this post on your Blog/Website :