Function in c language(defination and declaration)
vk12450
1,094 views
16 slides
Jan 16, 2018
Slide 1 of 16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
About This Presentation
Function in C language(Defination and Declaration)
Size: 1.14 MB
Language: en
Added: Jan 16, 2018
Slides: 16 pages
Slide Content
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 function Library 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; . . . . . . . . . . . . . . }
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.