SlideShare a Scribd company logo
C PROGRAMMING
BY MOHAMMED TAJUDDIN
C PROGRAMMING
• Functions can be invoked in two ways: Call by Value or Call by
Reference. These two ways are generally differentiated by the type of
values passed to them as parameters.
• The parameters passed to function are called actual parameters
whereas the parameters received by function are called formal
parameters.
C PROGRAMMING
• Call By Value: In this parameter passing method, values of actual
parameters are copied to function’s formal parameters and the two
types of parameters are stored in different memory locations. So any
changes made inside functions are not reflected in actual parameters
of the caller.
• Call by Reference: Both the actual and formal parameters refer to the
same locations, so any changes made inside the function are actually
reflected in actual parameters of the caller.
C PROGRAMMING
#include<stdio.h>
void swap(int,int);
void main(){
int a=10,b=20;
swap(a,b);}
printf(“%d%d”,a,b);}
void swap(int x,int y){
int t=x,x=y,y=t;
printf(“%d%d”,x,y);
}
C PROGRAMMING
#include<stdio.h>
void swap(int*,int*);
void main(){
int a=10,b=20;
printf(“%d%d”,a,b);
swap(&a,&b);}
void swap(int* x,int* y){
int t=*x,*x=*y,*y=t;
printf(“%d%d”,*x,*y);
}
C PROGRAMMING
Recursive function :
Function calling it self is called as recursive function.
Example :
#include<stdio.h>
int fact(int);
void main(){
int n,result;
printf(“enter number”);
scanf(“%d”,&n);
result=fact(n);
printf(“%d”,result);}
C PROGAMMING
int fact(int){
int res;
if(n==0){
res=1;}
else{
res=n*fact(n-1);}
return res;
}

More Related Content

Similar to FUNCTIONS1.pptx

User Defined Functions in C
User Defined Functions in CUser Defined Functions in C
User Defined Functions in C
RAJ KUMAR
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
JVenkateshGoud
 
Funtions of c programming. the functions of c helps to clarify all the tops
Funtions of c programming. the functions of c helps to clarify all the topsFuntions of c programming. the functions of c helps to clarify all the tops
Funtions of c programming. the functions of c helps to clarify all the tops
sameermhr345
 
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptxCH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
SangeetaBorde3
 
Subprogramms
SubprogrammsSubprogramms
Subprogramms
janapriyanaidu
 
PSPC-UNIT-4.pdf
PSPC-UNIT-4.pdfPSPC-UNIT-4.pdf
PSPC-UNIT-4.pdf
ArshiniGubbala3
 
USER DEFINED FUNCTIONS IN C.pdf
USER DEFINED FUNCTIONS IN C.pdfUSER DEFINED FUNCTIONS IN C.pdf
USER DEFINED FUNCTIONS IN C.pdf
BoomBoomers
 
Function in c
Function in cFunction in c
Function in c
savitamhaske
 
unit_2.pptx
unit_2.pptxunit_2.pptx
unit_2.pptx
Venkatesh Goud
 
Functions
Functions Functions
Functions
Praneeth960856
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
LGirija
 
16717 functions in C++
16717 functions in C++16717 functions in C++
16717 functions in C++
LPU
 
4th unit full
4th unit full4th unit full
4th unit full
Murali Saktheeswaran
 
Global variables, sorting static variables,function and arrays,
Global variables, sorting static variables,function and arrays,Global variables, sorting static variables,function and arrays,
Global variables, sorting static variables,function and arrays,
Ahmad55ali
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
RSathyaPriyaCSEKIOT
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
Shuvongkor Barman
 
Pointers and call by value, reference, address in C
Pointers and call by value, reference, address in CPointers and call by value, reference, address in C
Pointers and call by value, reference, address in C
Syed Mustafa
 
Lecture6
Lecture6Lecture6
Functions.pptx
Functions.pptxFunctions.pptx
Functions.pptx
AkshayKumarK14
 
358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2
sumitbardhan
 

Similar to FUNCTIONS1.pptx (20)

User Defined Functions in C
User Defined Functions in CUser Defined Functions in C
User Defined Functions in C
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
 
Funtions of c programming. the functions of c helps to clarify all the tops
Funtions of c programming. the functions of c helps to clarify all the topsFuntions of c programming. the functions of c helps to clarify all the tops
Funtions of c programming. the functions of c helps to clarify all the tops
 
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptxCH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
 
Subprogramms
SubprogrammsSubprogramms
Subprogramms
 
PSPC-UNIT-4.pdf
PSPC-UNIT-4.pdfPSPC-UNIT-4.pdf
PSPC-UNIT-4.pdf
 
USER DEFINED FUNCTIONS IN C.pdf
USER DEFINED FUNCTIONS IN C.pdfUSER DEFINED FUNCTIONS IN C.pdf
USER DEFINED FUNCTIONS IN C.pdf
 
Function in c
Function in cFunction in c
Function in c
 
unit_2.pptx
unit_2.pptxunit_2.pptx
unit_2.pptx
 
Functions
Functions Functions
Functions
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
16717 functions in C++
16717 functions in C++16717 functions in C++
16717 functions in C++
 
4th unit full
4th unit full4th unit full
4th unit full
 
Global variables, sorting static variables,function and arrays,
Global variables, sorting static variables,function and arrays,Global variables, sorting static variables,function and arrays,
Global variables, sorting static variables,function and arrays,
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
Pointers and call by value, reference, address in C
Pointers and call by value, reference, address in CPointers and call by value, reference, address in C
Pointers and call by value, reference, address in C
 
Lecture6
Lecture6Lecture6
Lecture6
 
Functions.pptx
Functions.pptxFunctions.pptx
Functions.pptx
 
358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2
 

More from MohammedtajuddinTaju

EMBEDDED SYSTEM AUTOSAR.pdf
EMBEDDED SYSTEM AUTOSAR.pdfEMBEDDED SYSTEM AUTOSAR.pdf
EMBEDDED SYSTEM AUTOSAR.pdf
MohammedtajuddinTaju
 
numbers_systems.pptx
numbers_systems.pptxnumbers_systems.pptx
numbers_systems.pptx
MohammedtajuddinTaju
 
POINTERS.pptx
POINTERS.pptxPOINTERS.pptx
POINTERS.pptx
MohammedtajuddinTaju
 
Nested and Infinite loops.pptx
Nested and Infinite loops.pptxNested and Infinite loops.pptx
Nested and Infinite loops.pptx
MohammedtajuddinTaju
 
LOOPS IN C.pptx
LOOPS IN C.pptxLOOPS IN C.pptx
LOOPS IN C.pptx
MohammedtajuddinTaju
 
FUNCTIONS.pptx
FUNCTIONS.pptxFUNCTIONS.pptx
FUNCTIONS.pptx
MohammedtajuddinTaju
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS1.pptx
ARRAYS1.pptxARRAYS1.pptx
ARRAYS1.pptx
MohammedtajuddinTaju
 
DMA.pptx
DMA.pptxDMA.pptx
INTRODUCTION TO C LANGUAGE.pptx
INTRODUCTION TO C LANGUAGE.pptxINTRODUCTION TO C LANGUAGE.pptx
INTRODUCTION TO C LANGUAGE.pptx
MohammedtajuddinTaju
 
EMBEDDED SYSTEMS INTRODUCTION.pptx
EMBEDDED SYSTEMS INTRODUCTION.pptxEMBEDDED SYSTEMS INTRODUCTION.pptx
EMBEDDED SYSTEMS INTRODUCTION.pptx
MohammedtajuddinTaju
 
C PROGRAMING.pptx
C PROGRAMING.pptxC PROGRAMING.pptx
C PROGRAMING.pptx
MohammedtajuddinTaju
 

More from MohammedtajuddinTaju (12)

EMBEDDED SYSTEM AUTOSAR.pdf
EMBEDDED SYSTEM AUTOSAR.pdfEMBEDDED SYSTEM AUTOSAR.pdf
EMBEDDED SYSTEM AUTOSAR.pdf
 
numbers_systems.pptx
numbers_systems.pptxnumbers_systems.pptx
numbers_systems.pptx
 
POINTERS.pptx
POINTERS.pptxPOINTERS.pptx
POINTERS.pptx
 
Nested and Infinite loops.pptx
Nested and Infinite loops.pptxNested and Infinite loops.pptx
Nested and Infinite loops.pptx
 
LOOPS IN C.pptx
LOOPS IN C.pptxLOOPS IN C.pptx
LOOPS IN C.pptx
 
FUNCTIONS.pptx
FUNCTIONS.pptxFUNCTIONS.pptx
FUNCTIONS.pptx
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
ARRAYS1.pptx
ARRAYS1.pptxARRAYS1.pptx
ARRAYS1.pptx
 
DMA.pptx
DMA.pptxDMA.pptx
DMA.pptx
 
INTRODUCTION TO C LANGUAGE.pptx
INTRODUCTION TO C LANGUAGE.pptxINTRODUCTION TO C LANGUAGE.pptx
INTRODUCTION TO C LANGUAGE.pptx
 
EMBEDDED SYSTEMS INTRODUCTION.pptx
EMBEDDED SYSTEMS INTRODUCTION.pptxEMBEDDED SYSTEMS INTRODUCTION.pptx
EMBEDDED SYSTEMS INTRODUCTION.pptx
 
C PROGRAMING.pptx
C PROGRAMING.pptxC PROGRAMING.pptx
C PROGRAMING.pptx
 

FUNCTIONS1.pptx

  • 2. C PROGRAMMING • Functions can be invoked in two ways: Call by Value or Call by Reference. These two ways are generally differentiated by the type of values passed to them as parameters. • The parameters passed to function are called actual parameters whereas the parameters received by function are called formal parameters.
  • 3. C PROGRAMMING • Call By Value: In this parameter passing method, values of actual parameters are copied to function’s formal parameters and the two types of parameters are stored in different memory locations. So any changes made inside functions are not reflected in actual parameters of the caller. • Call by Reference: Both the actual and formal parameters refer to the same locations, so any changes made inside the function are actually reflected in actual parameters of the caller.
  • 4. C PROGRAMMING #include<stdio.h> void swap(int,int); void main(){ int a=10,b=20; swap(a,b);} printf(“%d%d”,a,b);} void swap(int x,int y){ int t=x,x=y,y=t; printf(“%d%d”,x,y); }
  • 5. C PROGRAMMING #include<stdio.h> void swap(int*,int*); void main(){ int a=10,b=20; printf(“%d%d”,a,b); swap(&a,&b);} void swap(int* x,int* y){ int t=*x,*x=*y,*y=t; printf(“%d%d”,*x,*y); }
  • 6. C PROGRAMMING Recursive function : Function calling it self is called as recursive function. Example : #include<stdio.h> int fact(int); void main(){ int n,result; printf(“enter number”); scanf(“%d”,&n); result=fact(n); printf(“%d”,result);}
  • 7. C PROGAMMING int fact(int){ int res; if(n==0){ res=1;} else{ res=n*fact(n-1);} return res; }