SlideShare a Scribd company logo
GROUP MEMBERS
The program may become too large and complex  and as a result the task of debugging, testing and maintaining becomes difficult. if a program is divided into functional parts , then each part may be independently coded and later combined into single unit .These sub programs are known as  functions
Functions are the user defined data types.  Functions are having modular approach. It facilitates top - down modular programming.  A function may be used by many other programs.  It is easy to locate and isolate faulty function for further investigations.
Functions are of two types : library functions User defined functions
main() printf() scanf() getch() sqrt() cos() strcat() And etc.
User defined functions are the functions which are defined by the user itself . Main Program Function2 Function3 Function 1
return type <function name > (arguments) {   local variable declarations ;   execute statement 1; execute statment2 ; … ..   … .. return (expression); }
A function must follow the same rules of information as other variables names . Additional care must be taken to avoid duplicating library routine names or operating system commands .
The arguments may be void. The argument list contains valid variable names separated by commas. The list must be surrounded by parenthesis . No semicolon follows the parenthesis. The argument receive value form the calling function ,thus providing a means for data communication from the calling function to the called function. All the arguments should be declare with its data type.
Categories of function  Category 1: Function with no arguments no return value Category 2: Functions with arguments and return values  Category 3: Functions with arguments and return values
 
Class student // declaration of class  { char name[15]; int rollno; float marks; public: void getdata() // Function declaration { cout<< “Input the name of the student” ; cin>>name;
cout<< “Input the rollno” ; cin>>rollno; cout<< “Input the marks of the student” ; cin>>marks; } void putdata() // declaration of another function { cout<< “Name = “ <<name<<endl; cout<< “Roll no = ” <<rollno<<endl; cout<< “Marks = ” <<marks<<endl; } };
main() { class student obj; obj.getdata(); // calling of the function  obj.putdata(); // calling of the another function getch(); }
Input the name of student XYZ Input the rollno 1 Input the marks of the student 49.02
 
#include<iostream.h> #include<conio.h> class add { int c; public: void sum(int a ,int b) { c=a+b ; cout<< “The addition is “ <<c; } }; Actual arguments
main() { cout<< “We are in main Function ”; add a; a.sum(10,20); getch(); } Formal Arguments
We are in main Function The addition is 30
The main objective of passing arguments to function is message passing. The message passing is also known as communication between two functions i.e., between caller and callee functions. There are three methods  which can pass values to the function:- Call by value (Pass by value) Call by address (Pass by address) Call by reference (pass by reference)
The value of the actual argument is passed to the formal arguments and operation is done on the formal arguments.  Any change in the formal arguments does not effect the actual arguments because formal arguments are photo copy of the actual arguments. When the function is called it does not affect the actual arguments. Changes are made in the f0rmal arguments are local to the block of called function
#include<iostream.h> #include<conio.h> main() { void change (int,int); int x=10; int y=20; change(x,y); getch(); } }
void change (int a , int b) { int temp; temp=a; a=b;   b=temp;  cout<<a<<endl<<b; }
Instead of passing values address is passed. Function operates on address rather than values. Formal arguments are pointers to the actual arguments. Changes made in the argument are permanent.
#include<iostream.h> #include<conio.h> main() { void change (int * , int *); int x=10; int y=20; change( &x , &y); getch(); } }
void change (int *a , int *b) { int  *temp; *temp = *a; *a = *b;   *b = *temp;  cout<<a<<endl<<b; }
When a function is declared as  inline  ,the compiler copies the code of the function in the calling function. Function body is inserted in place of function call during compilation. Passing of control between caller and callee function is avoided.
The inline function is mostly used when calling of function is small. it is advisable to use the inline function for small programs. Inline mechanism increases execution performance in terms of speed.the program using inline function needs more memory space since the inline functions are copied at every point
#include<iostream.h> #include<conio.h> Inline void sum(int a ,int b) { int c; c=a+b ; cout<< “The addition is “ <<c; }
main() { cout<< “We are in main Function ”; sum(10,20); getch(); }
If the functions is recursive. Function contain a static variables. Function contain control structures. Main function can not work as inline.
 

More Related Content

PPTX
functions of C++
PPTX
Functions in C
PPT
C++ Function
PPTX
Functions in c
ODP
Function
PPTX
Functions in C
PDF
Function lecture
PDF
Features of c
functions of C++
Functions in C
C++ Function
Functions in c
Function
Functions in C
Function lecture
Features of c

What's hot (20)

PDF
SPL 9 | Scope of Variables in C
PPT
Functions in C++
PDF
Types of pointer in C
PPTX
Pointers in c++
PPTX
Python Operators
PPT
Function in C Language
PPT
Lecture#6 functions in c++
PPTX
Presentation on Function in C Programming
PPTX
Decision making and branching in c programming
PPTX
Switch case in C++
PPTX
Intro to c++
PPTX
Functions in c++
PPT
Python GUI Programming
PDF
Exception handling
PPT
RECURSION IN C
DOCX
Features of c language 1
PDF
Python tuple
PPTX
Data types in c++
PPTX
Structure in C
PPTX
SPL 9 | Scope of Variables in C
Functions in C++
Types of pointer in C
Pointers in c++
Python Operators
Function in C Language
Lecture#6 functions in c++
Presentation on Function in C Programming
Decision making and branching in c programming
Switch case in C++
Intro to c++
Functions in c++
Python GUI Programming
Exception handling
RECURSION IN C
Features of c language 1
Python tuple
Data types in c++
Structure in C
Ad

Viewers also liked (20)

PPTX
Function in c
PPTX
Function in C program
PPTX
User defined functions in C
PDF
Function in C
PPTX
Presentation on function
PPT
user defined function
PPT
Basics of C programming
PDF
7 Slide Summary: HOW can India's Parliament function better?
DOCX
How to upgrade a renault duster stereo
PPT
Pre defined Functions in C
PPTX
C programming slide-6
PDF
Lecture20 user definedfunctions.ppt
PPT
C language control statements
PPT
Tokens_C
PPT
Recursion in c
PPT
Token system powerpoint
PDF
Branching in PowerPoint
PPT
Types of operators in C
PDF
Lecture13 control statementswitch.ppt
PDF
10. switch case
Function in c
Function in C program
User defined functions in C
Function in C
Presentation on function
user defined function
Basics of C programming
7 Slide Summary: HOW can India's Parliament function better?
How to upgrade a renault duster stereo
Pre defined Functions in C
C programming slide-6
Lecture20 user definedfunctions.ppt
C language control statements
Tokens_C
Recursion in c
Token system powerpoint
Branching in PowerPoint
Types of operators in C
Lecture13 control statementswitch.ppt
10. switch case
Ad

Similar to Prsentation on functions (20)

DOCX
Functions assignment
PPTX
Dti2143 chapter 5
PPT
16717 functions in C++
 
PPT
User Defined Functions in C
PPT
Functions
PPT
Unit 5 Foc
DOCX
Introduction to c programming
PPTX
C and C++ functions
PDF
Functions in C++.pdf
PPTX
Unit-III.pptx
PPT
Ch4 functions
PPT
Chapter Introduction to Modular Programming.ppt
PPT
chapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).ppt
PPTX
Inline Functions and Default arguments
PPTX
Amit user defined functions xi (2)
PPTX
PPTX
Function C++
PPTX
Function in c++
PPT
Recursion in C
PDF
PSPC-UNIT-4.pdf
Functions assignment
Dti2143 chapter 5
16717 functions in C++
 
User Defined Functions in C
Functions
Unit 5 Foc
Introduction to c programming
C and C++ functions
Functions in C++.pdf
Unit-III.pptx
Ch4 functions
Chapter Introduction to Modular Programming.ppt
chapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).ppt
Inline Functions and Default arguments
Amit user defined functions xi (2)
Function C++
Function in c++
Recursion in C
PSPC-UNIT-4.pdf

More from Alisha Korpal (20)

PPTX
Cyber crime and secuity
PPTX
Ppt on remote sensing system
PPT
Air crew
PPTX
Research presentaion on 2g,3g
PPT
PPT
Ppt on remote sensing system
DOC
Computer graphics report
PPT
Ppt on flat panel display
PPT
Java swings
DOC
Search engine
DOC
Report swings
PPT
Search engine
PPT
Artificial intelligence
DOC
AiArtificial Itelligence
PPT
Science and tecnology
DOC
Visual basic
PPT
Internet
DOC
Report on data link layer
PPT
Presentation on dll
DOC
Report on touch screen
Cyber crime and secuity
Ppt on remote sensing system
Air crew
Research presentaion on 2g,3g
Ppt on remote sensing system
Computer graphics report
Ppt on flat panel display
Java swings
Search engine
Report swings
Search engine
Artificial intelligence
AiArtificial Itelligence
Science and tecnology
Visual basic
Internet
Report on data link layer
Presentation on dll
Report on touch screen

Recently uploaded (20)

PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Basic Mud Logging Guide for educational purpose
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
VCE English Exam - Section C Student Revision Booklet
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Module 4: Burden of Disease Tutorial Slides S2 2025
O7-L3 Supply Chain Operations - ICLT Program
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Insiders guide to clinical Medicine.pdf
Final Presentation General Medicine 03-08-2024.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
Institutional Correction lecture only . . .
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Basic Mud Logging Guide for educational purpose
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Microbial disease of the cardiovascular and lymphatic systems
Microbial diseases, their pathogenesis and prophylaxis
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
STATICS OF THE RIGID BODIES Hibbelers.pdf
TR - Agricultural Crops Production NC III.pdf

Prsentation on functions

  • 2. The program may become too large and complex and as a result the task of debugging, testing and maintaining becomes difficult. if a program is divided into functional parts , then each part may be independently coded and later combined into single unit .These sub programs are known as functions
  • 3. Functions are the user defined data types. Functions are having modular approach. It facilitates top - down modular programming. A function may be used by many other programs. It is easy to locate and isolate faulty function for further investigations.
  • 4. Functions are of two types : library functions User defined functions
  • 5. main() printf() scanf() getch() sqrt() cos() strcat() And etc.
  • 6. User defined functions are the functions which are defined by the user itself . Main Program Function2 Function3 Function 1
  • 7. return type <function name > (arguments) { local variable declarations ; execute statement 1; execute statment2 ; … .. … .. return (expression); }
  • 8. A function must follow the same rules of information as other variables names . Additional care must be taken to avoid duplicating library routine names or operating system commands .
  • 9. The arguments may be void. The argument list contains valid variable names separated by commas. The list must be surrounded by parenthesis . No semicolon follows the parenthesis. The argument receive value form the calling function ,thus providing a means for data communication from the calling function to the called function. All the arguments should be declare with its data type.
  • 10. Categories of function Category 1: Function with no arguments no return value Category 2: Functions with arguments and return values Category 3: Functions with arguments and return values
  • 11.  
  • 12. Class student // declaration of class { char name[15]; int rollno; float marks; public: void getdata() // Function declaration { cout<< “Input the name of the student” ; cin>>name;
  • 13. cout<< “Input the rollno” ; cin>>rollno; cout<< “Input the marks of the student” ; cin>>marks; } void putdata() // declaration of another function { cout<< “Name = “ <<name<<endl; cout<< “Roll no = ” <<rollno<<endl; cout<< “Marks = ” <<marks<<endl; } };
  • 14. main() { class student obj; obj.getdata(); // calling of the function obj.putdata(); // calling of the another function getch(); }
  • 15. Input the name of student XYZ Input the rollno 1 Input the marks of the student 49.02
  • 16.  
  • 17. #include<iostream.h> #include<conio.h> class add { int c; public: void sum(int a ,int b) { c=a+b ; cout<< “The addition is “ <<c; } }; Actual arguments
  • 18. main() { cout<< “We are in main Function ”; add a; a.sum(10,20); getch(); } Formal Arguments
  • 19. We are in main Function The addition is 30
  • 20. The main objective of passing arguments to function is message passing. The message passing is also known as communication between two functions i.e., between caller and callee functions. There are three methods which can pass values to the function:- Call by value (Pass by value) Call by address (Pass by address) Call by reference (pass by reference)
  • 21. The value of the actual argument is passed to the formal arguments and operation is done on the formal arguments. Any change in the formal arguments does not effect the actual arguments because formal arguments are photo copy of the actual arguments. When the function is called it does not affect the actual arguments. Changes are made in the f0rmal arguments are local to the block of called function
  • 22. #include<iostream.h> #include<conio.h> main() { void change (int,int); int x=10; int y=20; change(x,y); getch(); } }
  • 23. void change (int a , int b) { int temp; temp=a; a=b; b=temp; cout<<a<<endl<<b; }
  • 24. Instead of passing values address is passed. Function operates on address rather than values. Formal arguments are pointers to the actual arguments. Changes made in the argument are permanent.
  • 25. #include<iostream.h> #include<conio.h> main() { void change (int * , int *); int x=10; int y=20; change( &x , &y); getch(); } }
  • 26. void change (int *a , int *b) { int *temp; *temp = *a; *a = *b; *b = *temp; cout<<a<<endl<<b; }
  • 27. When a function is declared as inline ,the compiler copies the code of the function in the calling function. Function body is inserted in place of function call during compilation. Passing of control between caller and callee function is avoided.
  • 28. The inline function is mostly used when calling of function is small. it is advisable to use the inline function for small programs. Inline mechanism increases execution performance in terms of speed.the program using inline function needs more memory space since the inline functions are copied at every point
  • 29. #include<iostream.h> #include<conio.h> Inline void sum(int a ,int b) { int c; c=a+b ; cout<< “The addition is “ <<c; }
  • 30. main() { cout<< “We are in main Function ”; sum(10,20); getch(); }
  • 31. If the functions is recursive. Function contain a static variables. Function contain control structures. Main function can not work as inline.
  • 32.