SlideShare una empresa de Scribd logo
1 de 19
Descargar para leer sin conexión
Categories of
   User Defined Functions in ‘C’

                      Prakash Khaire
           Lecturer, B V Patel Inst. of BMC & IT, Gopal
                           Vidyanagar
Prakash Khaire,       B V Patel Inst. Of BMC &




                                                          *
Lecturer              IT, Gopal Vidyanagar
Introduction
Introduction           Functions are categorized based on the arguments are
                       ●
                   passed or whether a value is returned or not
Category 1

Category 2
                                ●Functions with no agruments and no return values.
                                ●Functions with arguments and no return values.

Category 3                      ●Functions with arguments and one return value.
                                ●Functions with no arguments but return a vlues.

Category 4                      ●Functions that return multiple values


Category 5


Recursion




                                                                                              *
     Prakash Khaire,
     Prakash Khaire, Lecturer       B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                       BMC & IT, Gopal IT, Gopal Vidyanagar
Functions with no arguments and no return values
Introduction
                  ●You do not pass data to the called function.
Category 1        ●function with no return type does not pass

Category 2        back data to the calling function.
                  ●This type of function which does not return
Category 3
                  any value cannot be used in an expression
Category 4
                  it can be used only as independent
Category 5        statement.
Recursion




                                                                                          *
     Prakash Khaire,
     Prakash Khaire, Lecturer   B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                   BMC & IT, Gopal IT, Gopal Vidyanagar
Functions with no arguments and no return values
Introduction       #include<stdio.h>
                   #include<conio.h>                   void main()
Category 1         void printline()                    {
                   {                                     clrscr();
Category 2              int i;                           printf("Welcome to function in C");
                        printf("n");                    printline();
                        for(i=0;i<30;i++)                printf("Function easy to learn.");
Category 3             {
                                                         printline();
                            printf("-");
Category 4               }                               getch();
                         printf("n");                 }
Category 5         }

Recursion




                                                                                           *
     Prakash Khaire,
     Prakash Khaire, Lecturer    B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                    BMC & IT, Gopal IT, Gopal Vidyanagar
Functions with no arguments and no return values
Introduction

Category 1

Category 2

Category 3


Category 4

Category 5


Recursion




                                                                                          *
     Prakash Khaire,
     Prakash Khaire, Lecturer   B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                   BMC & IT, Gopal IT, Gopal Vidyanagar
Functions with arguments and no return value
Introduction
                  ●It accept data from calling function.
Category 1        ●you send data to the called function from

Category 2        calling function but you cannot send result
Category 3
                  data back to the calling function.
Category 4

Category 5


Recursion




                                                                                          *
     Prakash Khaire,
     Prakash Khaire, Lecturer   B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                   BMC & IT, Gopal IT, Gopal Vidyanagar
Functions with arguments and no return value
Introduction       #include<stdio.h>                           void main()
                   #include<conio.h>                           {
Category 1         void add(int x, int y)                        clrscr();
                   {                                             add(30,15);
Category 2         int result;                                   add(63,49);
                   result = x+y;                                 add(952,321);
                   printf("Sum of %d and %d is %d.nn",x,y,     getch();
Category 3         result);                                    }
                   }
Category 4

Category 5


Recursion




                                                                                          *
     Prakash Khaire,
     Prakash Khaire, Lecturer   B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                   BMC & IT, Gopal IT, Gopal Vidyanagar
Functions with arguments and no return value
Introduction

Category 1

Category 2

Category 3


Category 4

Category 5


Recursion




                                                                                          *
     Prakash Khaire,
     Prakash Khaire, Lecturer   B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                   BMC & IT, Gopal IT, Gopal Vidyanagar
Functions with arguments and return value
Introduction      ●It can send arguments (data) from the calling function to the
                  called function
Category 1
                  ●It wait for the result to be returned back from the called function

Category 2
                  back to the calling function
                  ●This type of function is mostly used in programming world

Category 3        because it can do two way communications
                  ●It can accept data as arguments as well as can send back data
Category 4        as return value
                  ●The data returned by the function can be used later in our
Category 5        program for further calculations.
Recursion




                                                                                          *
     Prakash Khaire,
     Prakash Khaire, Lecturer   B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                   BMC & IT, Gopal IT, Gopal Vidyanagar
Functions with arguments and return value
Introduction       #include<stdio.h>           void main()
                   #include<conio.h>           {
Category 1
                   int add(int x, int y)          int z;
Category 2
                   {                              clrscr();
                   int result;                    z = add(952,321);
Category 3         result = x+y;                  printf("Result %d.nn",add(30,55));
                   return(result);                printf("Result %d.nn",z);
Category 4         }                              getch();
                                               }
Category 5


Recursion




                                                                                          *
     Prakash Khaire,
     Prakash Khaire, Lecturer   B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                   BMC & IT, Gopal IT, Gopal Vidyanagar
Functions with arguments and return value
Introduction

Category 1

Category 2

Category 3


Category 4

Category 5


Recursion




                                                                                          *
     Prakash Khaire,
     Prakash Khaire, Lecturer   B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                   BMC & IT, Gopal IT, Gopal Vidyanagar
Functions with no arguments but returns value
Introduction
                  ●A function which does not take any
Category 1        argument but only returns values to the
Category 2        calling function.
                  ●The best example of this type of function is
Category 3
                  “getchar()” library function which is declared
Category 4
                  in the header file “stdio.h”.
Category 5


Recursion




                                                                                          *
     Prakash Khaire,
     Prakash Khaire, Lecturer   B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                   BMC & IT, Gopal IT, Gopal Vidyanagar
Functions with no arguments but returns value
Introduction       #include<stdio.h>
                                                      void main()
                   #include<conio.h>
Category 1                                            {
                   int send()
                                                          int z;
                   {
Category 2                                                clrscr();
                        int no1;
                                                          z = send();
Category 3              printf("Enter a no : ");
                                                          printf("nYou entered : %d.", z);
                        scanf("%d",&no1);
                                                          getch();
Category 4              return(no1);
                                                      }
                   }
Category 5


Recursion




                                                                                          *
     Prakash Khaire,
     Prakash Khaire, Lecturer   B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                   BMC & IT, Gopal IT, Gopal Vidyanagar
Functions with no arguments but returns value
Introduction

Category 1

Category 2

Category 3


Category 4

Category 5


Recursion




                                                                                          *
     Prakash Khaire,
     Prakash Khaire, Lecturer   B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                   BMC & IT, Gopal IT, Gopal Vidyanagar
Functions that return multiple values
Introduction
                  ●To send values to the called function, in the
Category 1        same way we can also use arguments to
Category 2        send back information to the calling function
                  ●The arguments that are used to send back
Category 3
                  data are called Output Parameters.
Category 4

Category 5


Recursion




                                                                                          *
     Prakash Khaire,
     Prakash Khaire, Lecturer   B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                   BMC & IT, Gopal IT, Gopal Vidyanagar
Functions that return multiple values
Introduction       #include<stdio.h>
                                                      void main()
                   #include<conio.h>
Category 1                                            {
                   void calc(int x, int y, int
                                                      int a=20, b=11, p,q;
                   *add, int *sub)
Category 2                                            clrscr();
                   {
                                                      calc(a,b,&p,&q);
Category 3         *add = x+y;
                                                      printf("Sum = %d, Sub = %d",p,q);
                   *sub = x-y;
                                                      getch();
Category 4         }
                                                      }
Category 5


Recursion




                                                                                          *
     Prakash Khaire,
     Prakash Khaire, Lecturer   B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                   BMC & IT, Gopal IT, Gopal Vidyanagar
Recursion
Introduction
                 ●A function calling itself again and again to
Category 1
                 compute a value
Category 2       ●Normally function are called by main

Category 3       function or by some another function
                 ●But in recursion the same function is called
Category 4
                 by itself repeatedly
Category 5


Recursion




                                                                                          *
     Prakash Khaire,
     Prakash Khaire, Lecturer   B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                   BMC & IT, Gopal IT, Gopal Vidyanagar
Closing
Introduction
                    int fact(int k)               1st call -> return(4 * fact(4-1));
                    {                                   return(4 * fact(3));
Category 1                if(k==0)                2nd call -> return(3 * fact(3-1));
                          {                             return(3 * fact(2));
Category 2                       return(1);             3rd call -> return(2 * fact(2-1));
                          }                             return(2 * fact(1));
Category 3                else
                          {
Category 4
                                 return(k * fact(k-1));
                          }
                    }
Category 5


Recursion




                                                                                             *
     Prakash Khaire,
     Prakash Khaire, Lecturer      B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                      BMC & IT, Gopal IT, Gopal Vidyanagar
Use of Recursive Function
Introduction
                 ●Recursive functions are written with less
Category 1
                 number of statements compared functions
Category 2       ●Recursion is effective where terms are

Category 3       generated successively to compute a value
Category 4

Category 5


Recursion




                                                                                          *
     Prakash Khaire,
     Prakash Khaire, Lecturer   B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar
                                                   BMC & IT, Gopal IT, Gopal Vidyanagar

Más contenido relacionado

La actualidad más candente

Operator Overloading and Scope of Variable
Operator Overloading and Scope of VariableOperator Overloading and Scope of Variable
Operator Overloading and Scope of VariableMOHIT DADU
 
structured programming
structured programmingstructured programming
structured programmingAhmad54321
 
Functions in C - Programming
Functions in C - Programming Functions in C - Programming
Functions in C - Programming GaurangVishnoi
 
predefined and user defined functions
predefined and user defined functionspredefined and user defined functions
predefined and user defined functionsSwapnil Yadav
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and typesimtiazalijoono
 
Functions in c
Functions in cFunctions in c
Functions in creshmy12
 
Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)nirajmandaliya
 
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 CSyed Mustafa
 
User defined functions in C programmig
User defined functions in C programmigUser defined functions in C programmig
User defined functions in C programmigAppili Vamsi Krishna
 
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in CHarendra Singh
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide shareDevashish Kumar
 

La actualidad más candente (20)

Operator Overloading and Scope of Variable
Operator Overloading and Scope of VariableOperator Overloading and Scope of Variable
Operator Overloading and Scope of Variable
 
structured programming
structured programmingstructured programming
structured programming
 
user defined function
user defined functionuser defined function
user defined function
 
Functions in C - Programming
Functions in C - Programming Functions in C - Programming
Functions in C - Programming
 
predefined and user defined functions
predefined and user defined functionspredefined and user defined functions
predefined and user defined functions
 
User defined functions
User defined functionsUser defined functions
User defined functions
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Functions
FunctionsFunctions
Functions
 
Functions
FunctionsFunctions
Functions
 
Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
 
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
 
User defined functions in C programmig
User defined functions in C programmigUser defined functions in C programmig
User defined functions in C programmig
 
Scope of variables
Scope of variablesScope of variables
Scope of variables
 
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Basics of cpp
Basics of cppBasics of cpp
Basics of cpp
 
4. function
4. function4. function
4. function
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
 

Destacado

Lecture15 comparisonoftheloopcontrolstructures.ppt
Lecture15 comparisonoftheloopcontrolstructures.pptLecture15 comparisonoftheloopcontrolstructures.ppt
Lecture15 comparisonoftheloopcontrolstructures.ppteShikshak
 
Html phrase tags
Html phrase tagsHtml phrase tags
Html phrase tagseShikshak
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’eShikshak
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variableseShikshak
 
Lecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operatorsLecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operatorseShikshak
 
Lecture7relationalandlogicaloperators 110823181038-phpapp02
Lecture7relationalandlogicaloperators 110823181038-phpapp02Lecture7relationalandlogicaloperators 110823181038-phpapp02
Lecture7relationalandlogicaloperators 110823181038-phpapp02eShikshak
 
Mesics lecture files in 'c'
Mesics lecture   files in 'c'Mesics lecture   files in 'c'
Mesics lecture files in 'c'eShikshak
 
Unit 1.3 types of cloud
Unit 1.3 types of cloudUnit 1.3 types of cloud
Unit 1.3 types of cloudeShikshak
 
Mesics lecture 8 arrays in 'c'
Mesics lecture 8   arrays in 'c'Mesics lecture 8   arrays in 'c'
Mesics lecture 8 arrays in 'c'eShikshak
 
Mesics lecture 7 iteration and repetitive executions
Mesics lecture 7   iteration and repetitive executionsMesics lecture 7   iteration and repetitive executions
Mesics lecture 7 iteration and repetitive executionseShikshak
 
Unit 1.1 introduction to cloud computing
Unit 1.1   introduction to cloud computingUnit 1.1   introduction to cloud computing
Unit 1.1 introduction to cloud computingeShikshak
 
Algorithm chapter 11
Algorithm chapter 11Algorithm chapter 11
Algorithm chapter 11chidabdu
 
Lecture19 unionsin c.ppt
Lecture19 unionsin c.pptLecture19 unionsin c.ppt
Lecture19 unionsin c.ppteShikshak
 
Unit 1.2 move to cloud computing
Unit 1.2   move to cloud computingUnit 1.2   move to cloud computing
Unit 1.2 move to cloud computingeShikshak
 
Html text and formatting
Html text and formattingHtml text and formatting
Html text and formattingeShikshak
 
Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssionseShikshak
 
Lecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.pptLecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.ppteShikshak
 
Lecture13 control statementswitch.ppt
Lecture13 control statementswitch.pptLecture13 control statementswitch.ppt
Lecture13 control statementswitch.ppteShikshak
 

Destacado (20)

Lecture15 comparisonoftheloopcontrolstructures.ppt
Lecture15 comparisonoftheloopcontrolstructures.pptLecture15 comparisonoftheloopcontrolstructures.ppt
Lecture15 comparisonoftheloopcontrolstructures.ppt
 
Html phrase tags
Html phrase tagsHtml phrase tags
Html phrase tags
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variables
 
Lecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operatorsLecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operators
 
Lecture7relationalandlogicaloperators 110823181038-phpapp02
Lecture7relationalandlogicaloperators 110823181038-phpapp02Lecture7relationalandlogicaloperators 110823181038-phpapp02
Lecture7relationalandlogicaloperators 110823181038-phpapp02
 
Mesics lecture files in 'c'
Mesics lecture   files in 'c'Mesics lecture   files in 'c'
Mesics lecture files in 'c'
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Unit 1.3 types of cloud
Unit 1.3 types of cloudUnit 1.3 types of cloud
Unit 1.3 types of cloud
 
Mesics lecture 8 arrays in 'c'
Mesics lecture 8   arrays in 'c'Mesics lecture 8   arrays in 'c'
Mesics lecture 8 arrays in 'c'
 
Mesics lecture 7 iteration and repetitive executions
Mesics lecture 7   iteration and repetitive executionsMesics lecture 7   iteration and repetitive executions
Mesics lecture 7 iteration and repetitive executions
 
Unit 1.1 introduction to cloud computing
Unit 1.1   introduction to cloud computingUnit 1.1   introduction to cloud computing
Unit 1.1 introduction to cloud computing
 
Algorithm chapter 11
Algorithm chapter 11Algorithm chapter 11
Algorithm chapter 11
 
Lecture19 unionsin c.ppt
Lecture19 unionsin c.pptLecture19 unionsin c.ppt
Lecture19 unionsin c.ppt
 
Unit 1.2 move to cloud computing
Unit 1.2   move to cloud computingUnit 1.2   move to cloud computing
Unit 1.2 move to cloud computing
 
Html text and formatting
Html text and formattingHtml text and formatting
Html text and formatting
 
Linked list
Linked listLinked list
Linked list
 
Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssions
 
Lecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.pptLecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.ppt
 
Lecture13 control statementswitch.ppt
Lecture13 control statementswitch.pptLecture13 control statementswitch.ppt
Lecture13 control statementswitch.ppt
 

Más de eShikshak

Modelling and evaluation
Modelling and evaluationModelling and evaluation
Modelling and evaluationeShikshak
 
Operators in python
Operators in pythonOperators in python
Operators in pythoneShikshak
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in pythoneShikshak
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythoneShikshak
 
Introduction to e commerce
Introduction to e commerceIntroduction to e commerce
Introduction to e commerceeShikshak
 
Chapeter 2 introduction to cloud computing
Chapeter 2   introduction to cloud computingChapeter 2   introduction to cloud computing
Chapeter 2 introduction to cloud computingeShikshak
 
Unit 1.4 working of cloud computing
Unit 1.4 working of cloud computingUnit 1.4 working of cloud computing
Unit 1.4 working of cloud computingeShikshak
 
Mesics lecture 6 control statement = if -else if__else
Mesics lecture 6   control statement = if -else if__elseMesics lecture 6   control statement = if -else if__else
Mesics lecture 6 control statement = if -else if__elseeShikshak
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’eShikshak
 
Lecture18 structurein c.ppt
Lecture18 structurein c.pptLecture18 structurein c.ppt
Lecture18 structurein c.ppteShikshak
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppteShikshak
 
Lecturer23 pointersin c.ppt
Lecturer23 pointersin c.pptLecturer23 pointersin c.ppt
Lecturer23 pointersin c.ppteShikshak
 
Program development cyle
Program development cyleProgram development cyle
Program development cyleeShikshak
 
Language processors
Language processorsLanguage processors
Language processorseShikshak
 
Computer programming programming_langugages
Computer programming programming_langugagesComputer programming programming_langugages
Computer programming programming_langugageseShikshak
 

Más de eShikshak (15)

Modelling and evaluation
Modelling and evaluationModelling and evaluation
Modelling and evaluation
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Introduction to e commerce
Introduction to e commerceIntroduction to e commerce
Introduction to e commerce
 
Chapeter 2 introduction to cloud computing
Chapeter 2   introduction to cloud computingChapeter 2   introduction to cloud computing
Chapeter 2 introduction to cloud computing
 
Unit 1.4 working of cloud computing
Unit 1.4 working of cloud computingUnit 1.4 working of cloud computing
Unit 1.4 working of cloud computing
 
Mesics lecture 6 control statement = if -else if__else
Mesics lecture 6   control statement = if -else if__elseMesics lecture 6   control statement = if -else if__else
Mesics lecture 6 control statement = if -else if__else
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
Lecture18 structurein c.ppt
Lecture18 structurein c.pptLecture18 structurein c.ppt
Lecture18 structurein c.ppt
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppt
 
Lecturer23 pointersin c.ppt
Lecturer23 pointersin c.pptLecturer23 pointersin c.ppt
Lecturer23 pointersin c.ppt
 
Program development cyle
Program development cyleProgram development cyle
Program development cyle
 
Language processors
Language processorsLanguage processors
Language processors
 
Computer programming programming_langugages
Computer programming programming_langugagesComputer programming programming_langugages
Computer programming programming_langugages
 

Último

Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 

Último (20)

Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Lecture21 categoriesof userdefinedfunctions.ppt

  • 1. Categories of User Defined Functions in ‘C’ Prakash Khaire Lecturer, B V Patel Inst. of BMC & IT, Gopal Vidyanagar Prakash Khaire, B V Patel Inst. Of BMC & * Lecturer IT, Gopal Vidyanagar
  • 2. Introduction Introduction Functions are categorized based on the arguments are ● passed or whether a value is returned or not Category 1 Category 2 ●Functions with no agruments and no return values. ●Functions with arguments and no return values. Category 3 ●Functions with arguments and one return value. ●Functions with no arguments but return a vlues. Category 4 ●Functions that return multiple values Category 5 Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 3. Functions with no arguments and no return values Introduction ●You do not pass data to the called function. Category 1 ●function with no return type does not pass Category 2 back data to the calling function. ●This type of function which does not return Category 3 any value cannot be used in an expression Category 4 it can be used only as independent Category 5 statement. Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 4. Functions with no arguments and no return values Introduction #include<stdio.h> #include<conio.h> void main() Category 1 void printline() { { clrscr(); Category 2 int i; printf("Welcome to function in C"); printf("n"); printline(); for(i=0;i<30;i++) printf("Function easy to learn."); Category 3 { printline(); printf("-"); Category 4 } getch(); printf("n"); } Category 5 } Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 5. Functions with no arguments and no return values Introduction Category 1 Category 2 Category 3 Category 4 Category 5 Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 6. Functions with arguments and no return value Introduction ●It accept data from calling function. Category 1 ●you send data to the called function from Category 2 calling function but you cannot send result Category 3 data back to the calling function. Category 4 Category 5 Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 7. Functions with arguments and no return value Introduction #include<stdio.h> void main() #include<conio.h> { Category 1 void add(int x, int y) clrscr(); { add(30,15); Category 2 int result; add(63,49); result = x+y; add(952,321); printf("Sum of %d and %d is %d.nn",x,y, getch(); Category 3 result); } } Category 4 Category 5 Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 8. Functions with arguments and no return value Introduction Category 1 Category 2 Category 3 Category 4 Category 5 Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 9. Functions with arguments and return value Introduction ●It can send arguments (data) from the calling function to the called function Category 1 ●It wait for the result to be returned back from the called function Category 2 back to the calling function ●This type of function is mostly used in programming world Category 3 because it can do two way communications ●It can accept data as arguments as well as can send back data Category 4 as return value ●The data returned by the function can be used later in our Category 5 program for further calculations. Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 10. Functions with arguments and return value Introduction #include<stdio.h> void main() #include<conio.h> { Category 1 int add(int x, int y) int z; Category 2 { clrscr(); int result; z = add(952,321); Category 3 result = x+y; printf("Result %d.nn",add(30,55)); return(result); printf("Result %d.nn",z); Category 4 } getch(); } Category 5 Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 11. Functions with arguments and return value Introduction Category 1 Category 2 Category 3 Category 4 Category 5 Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 12. Functions with no arguments but returns value Introduction ●A function which does not take any Category 1 argument but only returns values to the Category 2 calling function. ●The best example of this type of function is Category 3 “getchar()” library function which is declared Category 4 in the header file “stdio.h”. Category 5 Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 13. Functions with no arguments but returns value Introduction #include<stdio.h> void main() #include<conio.h> Category 1 { int send() int z; { Category 2 clrscr(); int no1; z = send(); Category 3 printf("Enter a no : "); printf("nYou entered : %d.", z); scanf("%d",&no1); getch(); Category 4 return(no1); } } Category 5 Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 14. Functions with no arguments but returns value Introduction Category 1 Category 2 Category 3 Category 4 Category 5 Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 15. Functions that return multiple values Introduction ●To send values to the called function, in the Category 1 same way we can also use arguments to Category 2 send back information to the calling function ●The arguments that are used to send back Category 3 data are called Output Parameters. Category 4 Category 5 Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 16. Functions that return multiple values Introduction #include<stdio.h> void main() #include<conio.h> Category 1 { void calc(int x, int y, int int a=20, b=11, p,q; *add, int *sub) Category 2 clrscr(); { calc(a,b,&p,&q); Category 3 *add = x+y; printf("Sum = %d, Sub = %d",p,q); *sub = x-y; getch(); Category 4 } } Category 5 Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 17. Recursion Introduction ●A function calling itself again and again to Category 1 compute a value Category 2 ●Normally function are called by main Category 3 function or by some another function ●But in recursion the same function is called Category 4 by itself repeatedly Category 5 Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 18. Closing Introduction int fact(int k) 1st call -> return(4 * fact(4-1)); { return(4 * fact(3)); Category 1 if(k==0) 2nd call -> return(3 * fact(3-1)); { return(3 * fact(2)); Category 2 return(1); 3rd call -> return(2 * fact(2-1)); } return(2 * fact(1)); Category 3 else { Category 4 return(k * fact(k-1)); } } Category 5 Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar
  • 19. Use of Recursive Function Introduction ●Recursive functions are written with less Category 1 number of statements compared functions Category 2 ●Recursion is effective where terms are Category 3 generated successively to compute a value Category 4 Category 5 Recursion * Prakash Khaire, Prakash Khaire, Lecturer B V Patel Inst. Of B V Patel Inst. Of BMC & Vidyanagar BMC & IT, Gopal IT, Gopal Vidyanagar