function-definition, need, declaration, definition, arguments, return value

11
C PROGRAM PRESENTATION GGS INDRAPRASTH UNIVERSITY Submitted to Submitted by Ms. Madhu Chauhan Manish Assistant Professor 048 BCA E1 2016-2019

Upload: manish-maurya

Post on 21-Apr-2017

174 views

Category:

Education


1 download

TRANSCRIPT

Page 1: Function-Definition, Need, Declaration, Definition, Arguments, Return Value

C PROGRAM PRESENTATION

GGS INDRAPRASTH UNIVERSITY

Submitted to Submitted byMs. Madhu Chauhan ManishAssistant Professor 048

BCA E1 2016-2019

Page 2: Function-Definition, Need, Declaration, Definition, Arguments, Return Value

Topic Function-Definition, Need,

Declaration, Definition, Arguments, Return Value.

Page 3: Function-Definition, Need, Declaration, Definition, Arguments, Return Value

Function-Definition A function is a group of statements that

together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions.

A function declaration tells the compiler about a function's name, return type, and parameters.

Page 4: Function-Definition, Need, Declaration, Definition, Arguments, Return Value

Need The C standard library provides numerous

built-in functions that your program can call. For example, strcat() to concatenate two strings, memcpy() to copy one memory location to another location, and many more functions.

No Need to copy code just call by its function name

Page 5: Function-Definition, Need, Declaration, Definition, Arguments, Return Value

Function Declarations

Page 6: Function-Definition, Need, Declaration, Definition, Arguments, Return Value

Function Arguments In programming, argument refers to the

variable passed to the function. Parameters a and b accepts the passed

arguments in the function definition. These arguments are called formal parameters of the function.

Page 7: Function-Definition, Need, Declaration, Definition, Arguments, Return Value

Example of an Argument

Page 8: Function-Definition, Need, Declaration, Definition, Arguments, Return Value

Syntax#include<stdio.h>#include<conio.h>return_type function_name (parameter list);{local declaration;Statements;return statement;}

Page 9: Function-Definition, Need, Declaration, Definition, Arguments, Return Value

Return Value The return statement terminates the execution of

a function and returns a value to the calling function.

Page 10: Function-Definition, Need, Declaration, Definition, Arguments, Return Value

Example Program to add two numbers with arguments and return value

#include<stdio.h> #include<conio.h> //headersInt sq(int num) //return type function name and argument{int ans; ans=num*num; //statementreturn(ans); //returning value of ans } void main()printf(“Enter the number”);scanf(“%d”,&num); result=sq(num); //value of above programprintf(“%d”,result);}

Page 11: Function-Definition, Need, Declaration, Definition, Arguments, Return Value

Thank you