You are on page 1of 18

Categories of user

defined function
tccicomputercoaching.com
tccicomputercoaching.com
tccicomputercoaching.com

 Here, we will learn about category of functions in C programming


language.

 These categories depend on Parameter and function parameter.

 A parameter is a variable that we use in a function definition. An


argument is the actual data that we pass to the function parameter.
tccicomputercoaching.com

Example:

#include <studio.h>

//Function declaration

intgetsum(int, int);
tccicomputercoaching.com

int main(void) {

/**

* We are calling the getArea() function

* The arguments passed to the function are 10 and 20.

*/

int area = getsum(10, 20);


tccicomputercoaching.com

 //output

printf("Sum: %d\n", sum);

return 0;

/**
tccicomputercoaching.com

 Function definition

* Following are the parameters of the given function


getArea()

* Length

* Width
tccicomputercoaching.com

*/

intgetsum(int a, int b) {

return (a+b);

}
tccicomputercoaching.com

 These categories depend on Function Parameter and


Function Argument:

 a. Function with no argument and no return value.

 To create a function with no argument and no return


value we set the parameter list to void and the return
type of the function to void.
tccicomputercoaching.com

For example,

void print10() {

printf("10");

}
tccicomputercoaching.com

 b. Function with no argument but returns a value.

 -For this type of functions we have void in the parameter


list but we set the return type to match the type of value
returned by the function.
tccicomputercoaching.com

For example,

int get10(void) {

return 10;

}
tccicomputercoaching.com

 c. Function with argument but no return value.

 -In this type of functions we have the return type set to


void but the parameter list is set to accept some
argument.
tccicomputercoaching.com

For example,

voidgetNumber(intnum) {

printf("Number: %d", num);

}
tccicomputercoaching.com

• d. Function with argument and returns a value.

• -In this type of functions we set both the parameter list


and the return type.
tccicomputercoaching.com

For example,

floatgetArea(float length, float width) {

return length * width;

}
tccicomputercoaching.com

To learn more in detail about C Language, Programming


Language,TCCI

Call us @ 9825618292

Visit us @ www.tccicomputercoaching.com
tccicomputercoaching.com

Thank You For Watching

You might also like