0% found this document useful (0 votes)
14 views3 pages

Function Definition: Rohini College of Engineering and Technology

The document explains the definition and implementation of functions in C programming, detailing the syntax and structure of function headers and bodies. It includes an example of a function that calculates the area of a circle, demonstrating function declaration, definition, and calling. Key components such as return types, parameter lists, and the use of return statements are also highlighted.

Uploaded by

Kavitha Ms
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

Function Definition: Rohini College of Engineering and Technology

The document explains the definition and implementation of functions in C programming, detailing the syntax and structure of function headers and bodies. It includes an example of a function that calculates the area of a circle, demonstrating function declaration, definition, and calling. Key components such as return types, parameter lists, and the use of return statements are also highlighted.

Uploaded by

Kavitha Ms
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ROHINI COLLEGE OF ENGINEERING AND TECHNOLOGY

FUNCTION DEFINITION

It is also known as function implementation. When the function is defined, space is


allocated for that function in memory.

Syntax
returntype functionname (parameter list)
{
statements;
return (value);
}

Example
int abc(int, int, int) // Function declaration
void main()
{
int x,y,z;
abc(x,y,z) // Function Call


}
int abc(int i, int j, int k) // Function definition
{
…….
….
return (value);
}

CS8251 PROGRAMMING IN C
ROHINI COLLEGE OF ENGINEERING AND TECHNOLOGY

Every function definition consists of 2 parts:


a) Header of the function
b) Body of the function

a) Header of the function


The header of the function is not terminated with a semicolon. The return type and the
number & types of parameters must be same in both function header & function declaration.

Syntax:
returntype functionname (parameter list)

Where,
 Return type – data type of return value. It can be int, float, double, char, void etc.
 Function name – name of the function
 Parameter type list –It is a comma separated list of parameter types.
b) Body of the function

 It consists of a set of statements enclosed within curly braces.


 The return statement is used to return the result of the called function to the
calling function.
Program:

#include<stdio.h>
#include<conio.h>
float circlearea(int); //function prototype
void main()
{
int r;
float area;
printf(“Enter the radius \n”);
scanf(“%d”,&r);
area=circlearea(r); //function call

CS8251 PROGRAMMING IN C
ROHINI COLLEGE OF ENGINEERING AND TECHNOLOGY

printf(“Area of circle =%f\n”, area);


getch();
}
float circlearea(int r1)
{
return 3.14 * r1 * r1; //function definition
}
Output:

Enter the radius


2
Area of circle = 12.000

CS8251 PROGRAMMING IN C

You might also like