C PROGRAM
PRESENTATION
GGS INDRAPRASTHUNIVERSITY
Submitted to Submitted
by
Ms. Madhu Chauhan Manish
Assistant 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> //headers
Int sq(int num) //return type function name and argument
{
int ans;
ans=num*num; //statement
return(ans); //returning value of ans
}
void main()
printf(“Enter the number”);
scanf(“%d”,&num);
result=sq(num); //value of above program
printf(“%d”,result);
}
Thank you

Function-Definition, Need, Declaration, Definition, Arguments, Return Value

  • 1.
    C PROGRAM PRESENTATION GGS INDRAPRASTHUNIVERSITY Submittedto Submitted by Ms. Madhu Chauhan Manish Assistant Professor 048 BCA E1 2016-2019
  • 2.
    Topic  Function-Definition, Need,Declaration, Definition, Arguments, Return Value.
  • 3.
    Function-Definition  A functionis 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.
  • 4.
    Need  The Cstandard 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
  • 5.
  • 6.
    Function Arguments  Inprogramming, 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.
  • 7.
    Example of anArgument
  • 8.
    Syntax #include<stdio.h> #include<conio.h> return_type function_name (parameterlist); { local declaration; Statements; return statement; }
  • 9.
    Return Value  Thereturn statement terminates the execution of a function and returns a value to the calling function.
  • 10.
    Example  Program toadd two numbers with arguments and return value #include<stdio.h> #include<conio.h> //headers Int sq(int num) //return type function name and argument { int ans; ans=num*num; //statement return(ans); //returning value of ans } void main() printf(“Enter the number”); scanf(“%d”,&num); result=sq(num); //value of above program printf(“%d”,result); }
  • 11.

Editor's Notes

  • #3 A schedule design for optional periods of time/objectives.
  • #4 A schedule design for optional periods of time/objectives.
  • #5 Objectives for instruction and expected results and/or skills developed from learning.
  • #6 Relative vocabulary list.
  • #7 Example graph/chart.
  • #8 Example graph/chart.
  • #9 Conclusion to course, lecture, et al.