SlideShare a Scribd company logo
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

PPTX
Functions in c
PDF
Python algorithm
PPTX
Python Functions
PDF
Functions
PPTX
Functions in Python
PPTX
3 cs xii_python_functions _ parameter passing
PPTX
Function in c programming
Functions in c
Python algorithm
Python Functions
Functions
Functions in Python
3 cs xii_python_functions _ parameter passing
Function in c programming

What's hot (20)

PPT
Python Built-in Functions and Use cases
PPTX
Functions in python slide share
DOCX
Sp imp gtu
PDF
Python functional programming
PPTX
Functions in C
PDF
Function arguments In Python
PPTX
Storage classes in C
PPTX
Polymorphism
PPTX
Polymorphism and its types
PPT
JavaScript: The Language
PPTX
Parametricity
PPTX
Introduction To Programming with Python-1
PPTX
Storage classes in C
PPTX
2CPP18 - Modifiers
PPTX
PHP = PHunctional Programming
PPTX
Python Programming Basics for begginners
PPTX
Lesson 5 php operators
PPTX
Introduction To Programming with Python Lecture 2
PDF
Semantic Analysis of a C Program
KEY
Mypy pycon-fi-2012
Python Built-in Functions and Use cases
Functions in python slide share
Sp imp gtu
Python functional programming
Functions in C
Function arguments In Python
Storage classes in C
Polymorphism
Polymorphism and its types
JavaScript: The Language
Parametricity
Introduction To Programming with Python-1
Storage classes in C
2CPP18 - Modifiers
PHP = PHunctional Programming
Python Programming Basics for begginners
Lesson 5 php operators
Introduction To Programming with Python Lecture 2
Semantic Analysis of a C Program
Mypy pycon-fi-2012
Ad

Viewers also liked (8)

PPTX
4.arrays
PPTX
7.pointers
PPTX
3.looping(iteration statements)
PPTX
8.derived data types
PPTX
2.decision making
PPTX
1.getting started with c
PPTX
6.operators
PDF
Programming & Data Structure Lecture Notes
4.arrays
7.pointers
3.looping(iteration statements)
8.derived data types
2.decision making
1.getting started with c
6.operators
Programming & Data Structure Lecture Notes
Ad

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