KEMBAR78
Function in c language(defination and declaration) | PPTX
Function in C language
(Defination and Declaration)
Guided By Submitted By
Vikash Maurya
 What is C language ?
Developed in1971.
It is case sensible language.
It helps to communicate with computer.
It is High Level Programming Language.
DENNIS RITCHIE
Example:
#include<stdio.h>
#include<conio.h>
Void main() Keyword (main function)
{
int a , b; Identifier
clrscr();
a=1; Constant
b=2;
sum= a+b; Operator
Printf(“sum=%d”,sum); String
getch();
} Special Symbol
It is a set of block which perform specific tasks.
OR
The subprogram is called as a function.
A “C” program is a collection of one or more function.
“C” program contains at least one function which is main().
Types of Function
User define functionLibrary function
No Return Type Argument List
Return Type
Sub programs that is already defined in C language.
Syntax to call a function: function name();
Ex;- scanf(); printf(); clrscr(); memcpy(); strcat();
Such functions created by users
Steps for User Define Function
 Declaration of function.
 Defination of function.
 Call function.
DECLARATION OF FUNCTION:
Return Type Function Name Argument List
void
int
float
char
User define name
Ex:- Add
int a, int b
Etc…
Defination of function:
Return Type Function Name Argument List
{
statement;
statement;
. . . . . . .
. . . . . . .
}
Call function:
Function name();
How user-define function works
#include<stdio.h>
Void functionname()
{
. . . . . . . .
. . . . . . . .
}
int main()
{
. . . . . . . .
. . . . . . . .
functionname();
. . . . . . . .
. . . . . . . .
}
Output
Advantages of function:
 Program can be divided into a smaller, simple task.
 Allowing the code to be called many times.
 Easier error handling.
 Easier to read and update.
 Code reusability.
CONCLUSION:
 To avoid repetition of code and bulky programs functionally related statements are
isolated into a function.
 Function definition defines the body of the function.
 Function declaration specifies the return type of the function and the types of
parameters it accepts.
 It is very easy to perform by the given steps.
 It is used by one or more times.
THANK YOU

Function in c language(defination and declaration)

  • 1.
    Function in Clanguage (Defination and Declaration) Guided By Submitted By Vikash Maurya
  • 2.
     What isC language ? Developed in1971. It is case sensible language. It helps to communicate with computer. It is High Level Programming Language. DENNIS RITCHIE
  • 3.
    Example: #include<stdio.h> #include<conio.h> Void main() Keyword(main function) { int a , b; Identifier clrscr(); a=1; Constant b=2; sum= a+b; Operator Printf(“sum=%d”,sum); String getch(); } Special Symbol
  • 5.
    It is aset of block which perform specific tasks. OR The subprogram is called as a function. A “C” program is a collection of one or more function. “C” program contains at least one function which is main().
  • 6.
    Types of Function Userdefine functionLibrary function No Return Type Argument List Return Type Sub programs that is already defined in C language. Syntax to call a function: function name(); Ex;- scanf(); printf(); clrscr(); memcpy(); strcat(); Such functions created by users
  • 7.
    Steps for UserDefine Function  Declaration of function.  Defination of function.  Call function.
  • 8.
    DECLARATION OF FUNCTION: ReturnType Function Name Argument List void int float char User define name Ex:- Add int a, int b Etc…
  • 9.
    Defination of function: ReturnType Function Name Argument List { statement; statement; . . . . . . . . . . . . . . }
  • 10.
  • 11.
    How user-define functionworks #include<stdio.h> Void functionname() { . . . . . . . . . . . . . . . . } int main() { . . . . . . . . . . . . . . . . functionname(); . . . . . . . . . . . . . . . . }
  • 13.
  • 14.
    Advantages of function: Program can be divided into a smaller, simple task.  Allowing the code to be called many times.  Easier error handling.  Easier to read and update.  Code reusability.
  • 15.
    CONCLUSION:  To avoidrepetition of code and bulky programs functionally related statements are isolated into a function.  Function definition defines the body of the function.  Function declaration specifies the return type of the function and the types of parameters it accepts.  It is very easy to perform by the given steps.  It is used by one or more times.
  • 16.