C PROGRAM PRESENTATION
GGS INDRAPRASTH UNIVERSITY
Submitted to Submitted byMs. Madhu Chauhan ManishAssistant Professor 048
BCA E1 2016-2019
Topic 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.
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
Function Declarations
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.
Example of an Argument
Syntax#include<stdio.h>#include<conio.h>return_type function_name (parameter list);{local declaration;Statements;return statement;}
Return Value The return statement terminates the execution of
a function and returns a value to the calling function.
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);}
Thank you