SlideShare a Scribd company logo
1 of 22
FUNCTIONS IN PROGRAMMING
LANGUAGE
By:
Sadhana,
Shetty Mamatha Gopal,
Asst. Professors,
Dept. Of CS&E,
Sahyadri College Of Engineering &
Management.
Contents
• Introduction
• Terminology associated with functions
• Types of Functions
• Recursive Functions
Introduction
• The concept of functions is explained by
comparing it to real world scenario. Where a
team is assigned with the new task and the
team leader assigns the tasks to his
subordinates. This analogy is compared with
the concepts of functions.
What is function
• In information technology, the term
function has a number of meanings. In C
language and other programming, a
function is a named procedure that performs
a distinct service.
Terminology associated with functions
Parameters
Return Value
Categories of Functions
• Functions without, Parameters and Return
Value
• Functions with Parameters, without return
value
• Functions without Parameters, with return
value
• Functions with, Parameters and return value
Functions without, parameters and Return value
Syntax-Functions without, parameters and Return value
void CallingFunction()
{
CalledFunction();
}
void CalledFunction()
{
Read input
Perform task
Retain the result
}
Example-Functions without, parameters and Return value
void main()
{
add();
}
void add()
{
int a,b, sum;
printf(“Enter two valuesn”);
scanf(“%d%d”,&a,&b);
sum=a+b;
printf(“Sum=%d”,sum);
}
Functions with parameters, without Return value
Parameters
He will take the
parameters and add,
but keep the result to
himself
Syntax-Functions with parameters , without Return value
void Calling()
{
CalledFunc (actual Parameters);
}
void CalledFunc( formal parameters)
{
Perform task using formal parameters
Retain the result
}
example-Functions with parameters , without Return value
void main()
{
int a,b, sum;
printf(“Enter two valuesn”);
scanf(“%d%d”,&a,&b);
add(a,b);
}
void add( int a, int b)
{
int sum;
sum=a+b;
printf(“Sum=%d”,sum);
}
Functions without parameters, with Return value
I will not give you any
input, you take on your
own, perform task and
return me the result
He will take the input from
user, add and send back the
result to the boss
Syntax-Functions without parameters , with Return value
void CallingFunction()
{
Take the result =CalledFunction();
} return _type CalledFunction()
{
Read input
Perform task
Reurn the result
}
Example--Functions without parameters , with Return value
void main()
{
int result;
result=add();
printf(“Sum=%d”,result);
}
int add()
{
int a,b, sum;
printf(“Enter two valuesn”)
scanf(“%d%d”,&a,&b);
sum=a+b;
return sum;
}
Functions with, parameters and Return value
Take these parameters, add
them and return me the
result
He will take the
parameters and add, and
return the result to the
boss
Parameters
Syntax-Functions with parameters , with Return value
void Calling()
{
Take_the_result = CalledFunc (actual Parameters);
}
return_type CalledFunc( formal parameters)
{
Perform task using formal parameters
Return the result
}
Example--Functions with parameters , with Return value
void main()
{
int a,b, result;
printf(“Enter two valuesn”);
scanf(“%d%d”,&a,&b);
result=add(a,b);
printf(“Sum=%d”,result);
} int add( int a, int b)
{
int sum;
sum=a+b;
return sum;
}
Recursive Functions
FILL THE TANK
Yes done
with task
Syntax-of recursive functions
void Calling()
{
Take_the_result = CalledFunc (actual Parameters);
}
return_type CalledFunc( formal parameters)
{
Perform task using formal parameters
(call the called function)
Return the result
}
Example—RECURSIVE FUNCTIONS
void main()
{
int a,b, result;
printf(“Enter a numbern”);
scanf(“%d”,&a);
result=fact(a);
printf(“Factorial=%d”,result);
}
int fact( int a)
{
int f;
if(a==0) return 1;
else return a*fact(a-1);
}
Functions in programming language

More Related Content

What's hot

Inline Functions and Default arguments
Inline Functions and Default argumentsInline Functions and Default arguments
Inline Functions and Default argumentsNikhil Pandit
 
16717 functions in C++
16717 functions in C++16717 functions in C++
16717 functions in C++LPU
 
XII Computer Science- Chapter 1-Function
XII  Computer Science- Chapter 1-FunctionXII  Computer Science- Chapter 1-Function
XII Computer Science- Chapter 1-FunctionPrem Joel
 
Functions in C++ (OOP)
Functions in C++ (OOP)Functions in C++ (OOP)
Functions in C++ (OOP)Faizan Janjua
 
PARAMETER PASSING MECHANISMS
PARAMETER PASSING MECHANISMSPARAMETER PASSING MECHANISMS
PARAMETER PASSING MECHANISMSArpee Callejo
 
Handout # 3 functions c++
Handout # 3   functions c++Handout # 3   functions c++
Handout # 3 functions c++NUST Stuff
 
Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)Digvijaysinh Gohil
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++bajiajugal
 
Functions
FunctionsFunctions
FunctionsOnline
 
Basics of Functional Programming
Basics of Functional ProgrammingBasics of Functional Programming
Basics of Functional ProgrammingSartaj Singh
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C ProgrammingAnil Pokhrel
 
I am trying to figure out why my code won't work. It keeps telling me that my...
I am trying to figure out why my code won't work. It keeps telling me that my...I am trying to figure out why my code won't work. It keeps telling me that my...
I am trying to figure out why my code won't work. It keeps telling me that my...hwbloom460000
 
Inline function(oops)
Inline function(oops)Inline function(oops)
Inline function(oops)Jay Patel
 
Python Introduction | JNTUA | R19 | UNIT 1 | Functions
Python Introduction | JNTUA | R19 | UNIT 1 | FunctionsPython Introduction | JNTUA | R19 | UNIT 1 | Functions
Python Introduction | JNTUA | R19 | UNIT 1 | FunctionsFabMinds
 

What's hot (20)

Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Inline Functions and Default arguments
Inline Functions and Default argumentsInline Functions and Default arguments
Inline Functions and Default arguments
 
16717 functions in C++
16717 functions in C++16717 functions in C++
16717 functions in C++
 
XII Computer Science- Chapter 1-Function
XII  Computer Science- Chapter 1-FunctionXII  Computer Science- Chapter 1-Function
XII Computer Science- Chapter 1-Function
 
Functions in C++ (OOP)
Functions in C++ (OOP)Functions in C++ (OOP)
Functions in C++ (OOP)
 
PARAMETER PASSING MECHANISMS
PARAMETER PASSING MECHANISMSPARAMETER PASSING MECHANISMS
PARAMETER PASSING MECHANISMS
 
Parameter passing to_functions_in_c
Parameter passing to_functions_in_cParameter passing to_functions_in_c
Parameter passing to_functions_in_c
 
Function Pointer in C
Function Pointer in CFunction Pointer in C
Function Pointer in C
 
Handout # 3 functions c++
Handout # 3   functions c++Handout # 3   functions c++
Handout # 3 functions c++
 
Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++
 
Functions
FunctionsFunctions
Functions
 
Basics of Functional Programming
Basics of Functional ProgrammingBasics of Functional Programming
Basics of Functional Programming
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
 
I am trying to figure out why my code won't work. It keeps telling me that my...
I am trying to figure out why my code won't work. It keeps telling me that my...I am trying to figure out why my code won't work. It keeps telling me that my...
I am trying to figure out why my code won't work. It keeps telling me that my...
 
4th unit full
4th unit full4th unit full
4th unit full
 
Inline function(oops)
Inline function(oops)Inline function(oops)
Inline function(oops)
 
Ninth session
Ninth sessionNinth session
Ninth session
 
Functional programming 101
Functional programming 101Functional programming 101
Functional programming 101
 
Python Introduction | JNTUA | R19 | UNIT 1 | Functions
Python Introduction | JNTUA | R19 | UNIT 1 | FunctionsPython Introduction | JNTUA | R19 | UNIT 1 | Functions
Python Introduction | JNTUA | R19 | UNIT 1 | Functions
 

Similar to Functions in programming language

Similar to Functions in programming language (20)

Functions in C.pptx
Functions in C.pptxFunctions in C.pptx
Functions in C.pptx
 
6.3 c-Functions.ppt
6.3 c-Functions.ppt6.3 c-Functions.ppt
6.3 c-Functions.ppt
 
unit_2.pptx
unit_2.pptxunit_2.pptx
unit_2.pptx
 
Presentation 2 (1).pdf
Presentation 2 (1).pdfPresentation 2 (1).pdf
Presentation 2 (1).pdf
 
CHAPTER 6
CHAPTER 6CHAPTER 6
CHAPTER 6
 
Function
Function Function
Function
 
EST 102 Programming in C-MODULE 4
EST 102 Programming in C-MODULE 4EST 102 Programming in C-MODULE 4
EST 102 Programming in C-MODULE 4
 
Functions in C.pptx
Functions in C.pptxFunctions in C.pptx
Functions in C.pptx
 
Unit 4.pdf
Unit 4.pdfUnit 4.pdf
Unit 4.pdf
 
Unit 4 (1)
Unit 4 (1)Unit 4 (1)
Unit 4 (1)
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
 
Recursion in C
Recursion in CRecursion in C
Recursion in C
 
Updated Week 06 and 07 Functions In Python.pptx
Updated Week 06 and 07 Functions In Python.pptxUpdated Week 06 and 07 Functions In Python.pptx
Updated Week 06 and 07 Functions In Python.pptx
 
C function
C functionC function
C function
 
Function in c
Function in cFunction in c
Function in c
 
cp Module4(1)
cp Module4(1)cp Module4(1)
cp Module4(1)
 
Function in c
Function in cFunction in c
Function in c
 
Functionincprogram
FunctionincprogramFunctionincprogram
Functionincprogram
 
Embedded C - Day 2
Embedded C - Day 2Embedded C - Day 2
Embedded C - Day 2
 
Function in c program
Function in c programFunction in c program
Function in c program
 

Recently uploaded

Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...Call Girls in Nagpur High Profile
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Recently uploaded (20)

Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 

Functions in programming language

  • 1. FUNCTIONS IN PROGRAMMING LANGUAGE By: Sadhana, Shetty Mamatha Gopal, Asst. Professors, Dept. Of CS&E, Sahyadri College Of Engineering & Management.
  • 2. Contents • Introduction • Terminology associated with functions • Types of Functions • Recursive Functions
  • 3. Introduction • The concept of functions is explained by comparing it to real world scenario. Where a team is assigned with the new task and the team leader assigns the tasks to his subordinates. This analogy is compared with the concepts of functions.
  • 4. What is function • In information technology, the term function has a number of meanings. In C language and other programming, a function is a named procedure that performs a distinct service.
  • 5. Terminology associated with functions Parameters Return Value
  • 6. Categories of Functions • Functions without, Parameters and Return Value • Functions with Parameters, without return value • Functions without Parameters, with return value • Functions with, Parameters and return value
  • 7. Functions without, parameters and Return value
  • 8. Syntax-Functions without, parameters and Return value void CallingFunction() { CalledFunction(); } void CalledFunction() { Read input Perform task Retain the result }
  • 9. Example-Functions without, parameters and Return value void main() { add(); } void add() { int a,b, sum; printf(“Enter two valuesn”); scanf(“%d%d”,&a,&b); sum=a+b; printf(“Sum=%d”,sum); }
  • 10. Functions with parameters, without Return value Parameters He will take the parameters and add, but keep the result to himself
  • 11. Syntax-Functions with parameters , without Return value void Calling() { CalledFunc (actual Parameters); } void CalledFunc( formal parameters) { Perform task using formal parameters Retain the result }
  • 12. example-Functions with parameters , without Return value void main() { int a,b, sum; printf(“Enter two valuesn”); scanf(“%d%d”,&a,&b); add(a,b); } void add( int a, int b) { int sum; sum=a+b; printf(“Sum=%d”,sum); }
  • 13. Functions without parameters, with Return value I will not give you any input, you take on your own, perform task and return me the result He will take the input from user, add and send back the result to the boss
  • 14. Syntax-Functions without parameters , with Return value void CallingFunction() { Take the result =CalledFunction(); } return _type CalledFunction() { Read input Perform task Reurn the result }
  • 15. Example--Functions without parameters , with Return value void main() { int result; result=add(); printf(“Sum=%d”,result); } int add() { int a,b, sum; printf(“Enter two valuesn”) scanf(“%d%d”,&a,&b); sum=a+b; return sum; }
  • 16. Functions with, parameters and Return value Take these parameters, add them and return me the result He will take the parameters and add, and return the result to the boss Parameters
  • 17. Syntax-Functions with parameters , with Return value void Calling() { Take_the_result = CalledFunc (actual Parameters); } return_type CalledFunc( formal parameters) { Perform task using formal parameters Return the result }
  • 18. Example--Functions with parameters , with Return value void main() { int a,b, result; printf(“Enter two valuesn”); scanf(“%d%d”,&a,&b); result=add(a,b); printf(“Sum=%d”,result); } int add( int a, int b) { int sum; sum=a+b; return sum; }
  • 19. Recursive Functions FILL THE TANK Yes done with task
  • 20. Syntax-of recursive functions void Calling() { Take_the_result = CalledFunc (actual Parameters); } return_type CalledFunc( formal parameters) { Perform task using formal parameters (call the called function) Return the result }
  • 21. Example—RECURSIVE FUNCTIONS void main() { int a,b, result; printf(“Enter a numbern”); scanf(“%d”,&a); result=fact(a); printf(“Factorial=%d”,result); } int fact( int a) { int f; if(a==0) return 1; else return a*fact(a-1); }