C- PROGRAMMING 
FUNCTION
NOTES
System Define function 
#include<stdio.h> 
#include<conio.h> 
#include<math.h> 
void main() 
{ 
int num; 
float r; 
clrscr(); 
printf(“Enter any non”); 
scanf(“%d”,&num); 
r=sqrt(num); 
printf(“root of %d is %f n”, num,r); 
getch(); 
} 
EXTRA
NOTES
NOTES
User Define Function 
#include<stdio.h> Parameter and no return value 
#include<conio.h> 
void add(int, int); 
void main() 
{ 
int a,b; 
clrscr(); 
printf(“Enter two numbern”); 
scanf(“%d%d”,&a,&b); 
printf(“Value of A =%dn”,a); 
printf(“Value of B =%dn”,b); 
add(a,b); 
getch(); 
} no return 
void add(int x, int y) 
{ with Parameter 
int z; 
z=x+y; 
printf(“Sum of two no = %dn”,z); 
} 
EXTRA
User Define Function 
#include<stdio.h> Parameter and return value 
#include<conio.h> 
int add(int, int); 
void main() 
{ 
int a,b,c; 
clrscr(); 
printf(“Enter two numbern”); 
scanf(“%d%d”,&a,&b); 
printf(“Value of A =%dn”,a); 
printf(“Value of B =%dn”,b); 
c=add(a,b); 
printf(“Sum of two no = %dn”,c); 
getch(); 
} with return 
int add(int x, int y) 
{ with parameter 
int z; 
z=x+y; 
return z; 
} 
EXTRA
User Define Function 
No #include<stdio.h> Parameter and no return value 
#include<conio.h> 
void disp(); 
void main() 
{ 
clrscr(); 
disp(); 
getch(); 
} no return 
void disp() 
{ no parameter 
int a,b,c; 
printf(“Enter two numbern”); 
scanf(“%d%d”,&a,&b); 
printf(“Value of A =%dn”,a); 
printf(“Value of B =%dn”,b); 
c=a+b; 
printf(“Sum of two no = %dn”,c); 
getch(); 
} 
EXTRA
User Define Function 
No Parameter and return value 
#include<stdio.h> 
#include<conio.h> 
int fact(); 
void main() 
{ 
clrscr(); 
printf("Factorial %d",fact()); 
getch(); 
} with return 
int fact() 
{ no parameter 
int n,f=1; 
printf(" Enter any numbern"); 
scanf("%d",&n); 
while(n>=1) 
{ 
f=n*f; 
n--; 
} 
return f; 
} 
EXTRA
User Define Function 
Call by value method 
#include<stdio.h> 
#include<conio.h> 
void disp (int , int); 
void main() 
{ 
int a,b; 
clrscr(); 
printf(“Enter the Value of a & bn”); 
scanf(“%d%d”,&a,&b); 
printf(“Value of a before function %dn”,a); 
printf(“Value of b before function %dn”,b); 
disp(a,b); 
printf(“value of a after function %dn”,a); 
printf(“Value of b after function %dn”,b); 
getch(); 
} 
void disp(int a, int b) 
{ 
a=a+10; 
b=b+10; 
printf(“Value of a inside function %dn”,a); 
printf(“value of b inside function %dn”,b); 
} 
EXTRA
User Define Function 
Call by reference method 
#include<stdio.h> 
#include<conio.h> 
void disp (int &, int&); 
void main() 
{ 
int a,b; 
clrscr(); 
printf(“Enter the Value of a & bn”); 
scanf(“%d%d”,&a,&b); 
printf(“Value of a before function %dn”,a); 
printf(“Value of b before function %dn”,b); 
disp(a,b); 
printf(“value of a after function %dn”,a); 
printf(“Value of b after function %dn”,b); 
getch(); 
} 
void disp(int &a, int &b) 
{ 
a=a+10; 
b=b+10; 
printf(“Value of a inside function %dn”,a); 
printf(“value of b inside function %dn”,b); 
} 
EXTRA
NOTES
EXTRA
EXTRA
EXTRA
EXTRA
#include<stdio.h> 
#include<conio.h> 
int table(int,int); 
void main() 
{ 
int n,y=1,t; 
clrscr(); 
printf("Enter any non"); 
scanf("%d",&n); 
table(n,y); 
getch(); 
} 
int table(int n, int y) 
{ int t; 
if(y==11) 
{ 
return 0; 
} 
else 
{ t=n*y; 
printf("%d*%d=%dn",n,y,t); 
table(n,y+1); 
} 
return t; 
} 
EXTRA

C programming function

  • 1.
  • 2.
  • 3.
    System Define function #include<stdio.h> #include<conio.h> #include<math.h> void main() { int num; float r; clrscr(); printf(“Enter any non”); scanf(“%d”,&num); r=sqrt(num); printf(“root of %d is %f n”, num,r); getch(); } EXTRA
  • 4.
  • 5.
  • 6.
    User Define Function #include<stdio.h> Parameter and no return value #include<conio.h> void add(int, int); void main() { int a,b; clrscr(); printf(“Enter two numbern”); scanf(“%d%d”,&a,&b); printf(“Value of A =%dn”,a); printf(“Value of B =%dn”,b); add(a,b); getch(); } no return void add(int x, int y) { with Parameter int z; z=x+y; printf(“Sum of two no = %dn”,z); } EXTRA
  • 7.
    User Define Function #include<stdio.h> Parameter and return value #include<conio.h> int add(int, int); void main() { int a,b,c; clrscr(); printf(“Enter two numbern”); scanf(“%d%d”,&a,&b); printf(“Value of A =%dn”,a); printf(“Value of B =%dn”,b); c=add(a,b); printf(“Sum of two no = %dn”,c); getch(); } with return int add(int x, int y) { with parameter int z; z=x+y; return z; } EXTRA
  • 8.
    User Define Function No #include<stdio.h> Parameter and no return value #include<conio.h> void disp(); void main() { clrscr(); disp(); getch(); } no return void disp() { no parameter int a,b,c; printf(“Enter two numbern”); scanf(“%d%d”,&a,&b); printf(“Value of A =%dn”,a); printf(“Value of B =%dn”,b); c=a+b; printf(“Sum of two no = %dn”,c); getch(); } EXTRA
  • 9.
    User Define Function No Parameter and return value #include<stdio.h> #include<conio.h> int fact(); void main() { clrscr(); printf("Factorial %d",fact()); getch(); } with return int fact() { no parameter int n,f=1; printf(" Enter any numbern"); scanf("%d",&n); while(n>=1) { f=n*f; n--; } return f; } EXTRA
  • 10.
    User Define Function Call by value method #include<stdio.h> #include<conio.h> void disp (int , int); void main() { int a,b; clrscr(); printf(“Enter the Value of a & bn”); scanf(“%d%d”,&a,&b); printf(“Value of a before function %dn”,a); printf(“Value of b before function %dn”,b); disp(a,b); printf(“value of a after function %dn”,a); printf(“Value of b after function %dn”,b); getch(); } void disp(int a, int b) { a=a+10; b=b+10; printf(“Value of a inside function %dn”,a); printf(“value of b inside function %dn”,b); } EXTRA
  • 11.
    User Define Function Call by reference method #include<stdio.h> #include<conio.h> void disp (int &, int&); void main() { int a,b; clrscr(); printf(“Enter the Value of a & bn”); scanf(“%d%d”,&a,&b); printf(“Value of a before function %dn”,a); printf(“Value of b before function %dn”,b); disp(a,b); printf(“value of a after function %dn”,a); printf(“Value of b after function %dn”,b); getch(); } void disp(int &a, int &b) { a=a+10; b=b+10; printf(“Value of a inside function %dn”,a); printf(“value of b inside function %dn”,b); } EXTRA
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
    #include<stdio.h> #include<conio.h> inttable(int,int); void main() { int n,y=1,t; clrscr(); printf("Enter any non"); scanf("%d",&n); table(n,y); getch(); } int table(int n, int y) { int t; if(y==11) { return 0; } else { t=n*y; printf("%d*%d=%dn",n,y,t); table(n,y+1); } return t; } EXTRA