Function in c language(defination and declaration)

vk12450 1,094 views 16 slides Jan 16, 2018
Slide 1
Slide 1 of 16
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16

About This Presentation

Function in C language(Defination and Declaration)


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; . . . . . . . . . . . . . . }

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