SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Kürzlich hochgeladen (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

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