Professional Documents
Culture Documents
CONTENTS
INTRODUCTION
THE FORM OF C FUNCTIONS
RETURNS VALUES AND THEIR TYPES
CATEGORY OF FUNCTIONS
RECURSION
INTRODUCTION
Library functions
user-defined functions
LIBRAY FUNCTION
EXAMPLE
EXAMPLE
y=eee(a,b,c);
If a function does not return anything, then function access
eee(a,b,c);
KEY POINTS
y=eee();
The arguments appearing in the function call are
referred as actual arguments.
The arguments that appear in the first line of the
function definition is called formal argument.
EXAMPLE
GENERAL FORMAT
data type name( type 1 arg 1, type 2 arg 2,…type n arg n);
INFORMATION FROM FUNCTION PROTOTYPE
eee(a,b,c)
mul(a,b)
add(x,y)
square(y)
EXAMPLE
All argument variables must be declared for their types
after the function header and before the opening of the
function body.
ANOTHER FORMAT
eee(a,b,c)
int a,b,c; eee(int a, int b, int c)
KEY POINTS
return;
or
return(expression);
KEY POINTS
main(){
int p;
p=mul(5,2);
printf(“%d”,p);}
calling function
KEY POINTS
main(){
eee();
}
WRITE YOUR OWN FUNCTION
/* include header file here*/
/* function prototype here*/
main()
{
………}
ret-type1(param-list)
{
……}
.
.
ret-typen(param-list)
{
….}
CATEGORY OF A FUNCTION
#include<stdio.h>
#include<conio.h>
func1();
main(){
clrscr();
func1();
printf(“student”);
getch();
}
func1(){
printf(“eee”);
}
ARGUMENTS BUT NO RETURN VALUE
EXAMPLE recursion
recursion
main(){ recursion
printf(“recursion\n”); ……
main();
}
KEY POINTS