SlideShare a Scribd company logo
1 of 4
Functions
What you’ll learn:
o Introduction to functions
o Passing values to functions
What is a function?
 A function is a self-contained block of statement(s)/code that performs a unified task of
some kind.
 It is a re-usable code that can be used anywhere and anytime in the whole program.
Syntax of a function
return_type func_name (list_of_arguments);
return_type func_name (list_of_arguments) {
…block of code…
}
func_name(values_of_arguments);
Prototype Declaration:
Definition:
Calling:
Passing Arguments to Functions
int add (int a, int b) {
return a+b;
}
sum = add (i, j);
Formal Arguments
Actual Arguments
• While declaring and defining, formal arguments are used.
• While calling, actual arguments are used.

More Related Content

What's hot

Polymorphism
PolymorphismPolymorphism
Polymorphism
Amir Ali
 

What's hot (20)

Python Built-in Functions and Use cases
Python Built-in Functions and Use casesPython Built-in Functions and Use cases
Python Built-in Functions and Use cases
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Sp imp gtu
Sp imp gtuSp imp gtu
Sp imp gtu
 
Python functional programming
Python functional programmingPython functional programming
Python functional programming
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Function arguments In Python
Function arguments In PythonFunction arguments In Python
Function arguments In Python
 
Storage classes in C
Storage classes in CStorage classes in C
Storage classes in C
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Polymorphism and its types
Polymorphism and its typesPolymorphism and its types
Polymorphism and its types
 
JavaScript: The Language
JavaScript: The LanguageJavaScript: The Language
JavaScript: The Language
 
Parametricity
ParametricityParametricity
Parametricity
 
Introduction To Programming with Python-1
Introduction To Programming with Python-1Introduction To Programming with Python-1
Introduction To Programming with Python-1
 
Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C
 
2CPP18 - Modifiers
2CPP18 - Modifiers2CPP18 - Modifiers
2CPP18 - Modifiers
 
PHP = PHunctional Programming
PHP = PHunctional ProgrammingPHP = PHunctional Programming
PHP = PHunctional Programming
 
Python Programming Basics for begginners
Python Programming Basics for begginnersPython Programming Basics for begginners
Python Programming Basics for begginners
 
Lesson 5 php operators
Lesson 5   php operatorsLesson 5   php operators
Lesson 5 php operators
 
Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2
 
Semantic Analysis of a C Program
Semantic Analysis of a C ProgramSemantic Analysis of a C Program
Semantic Analysis of a C Program
 
Mypy pycon-fi-2012
Mypy pycon-fi-2012Mypy pycon-fi-2012
Mypy pycon-fi-2012
 

Viewers also liked (8)

4.arrays
4.arrays4.arrays
4.arrays
 
7.pointers
7.pointers7.pointers
7.pointers
 
3.looping(iteration statements)
3.looping(iteration statements)3.looping(iteration statements)
3.looping(iteration statements)
 
8.derived data types
8.derived data types8.derived data types
8.derived data types
 
2.decision making
2.decision making2.decision making
2.decision making
 
1.getting started with c
1.getting started with c1.getting started with c
1.getting started with c
 
6.operators
6.operators6.operators
6.operators
 
Programming & Data Structure Lecture Notes
Programming & Data Structure Lecture NotesProgramming & Data Structure Lecture Notes
Programming & Data Structure Lecture Notes
 

5.functions

  • 1. Functions What you’ll learn: o Introduction to functions o Passing values to functions
  • 2. What is a function?  A function is a self-contained block of statement(s)/code that performs a unified task of some kind.  It is a re-usable code that can be used anywhere and anytime in the whole program.
  • 3. Syntax of a function return_type func_name (list_of_arguments); return_type func_name (list_of_arguments) { …block of code… } func_name(values_of_arguments); Prototype Declaration: Definition: Calling:
  • 4. Passing Arguments to Functions int add (int a, int b) { return a+b; } sum = add (i, j); Formal Arguments Actual Arguments • While declaring and defining, formal arguments are used. • While calling, actual arguments are used.

Editor's Notes

  1. Hello