Function Introduction
Function are the blocks of C statements which perform specific task . Functions are used to divide the long program into sub program. In general a Function is a block of code that performs one or more action . Function can also be called by another Function. A program in the C language consists of several function .Every function has name and function can indicate with( ) . we can also declare the argument in the function.While defining function you must know these things:
Function are the blocks of C statements which perform specific task . Functions are used to divide the long program into sub program. In general a Function is a block of code that performs one or more action . Function can also be called by another Function. A program in the C language consists of several function .Every function has name and function can indicate with( ) . we can also declare the argument in the function.While defining function you must know these things:
1 function name
2 function return type ( if
the function does not return values then we can use void )
3 function argument
Syntax
Return type < function name
>< arguments>;
Function are two type
1 Built function
2 User define function
1 Built function : this function are those function which are
provided to us by the programming language .But before using these function we have to include some
header file like- stdio.h , string .h .
Some built function is
Math function –(sqrt() , pow
(),sign (), ceil() )
String function—( strupr (),
strlwr() , strrev(), strcmp() )
User defined function :--
these function are defined by the user according to their requirement . User defined function have four types :
1 with return with argument
2 with return without argument
3 without return with argument
4 without return without argument
Program
#include <stdio.h>
#include <conio.h>
void sum ( ); // function
declaration
void main
{
Clrscr();
Sum () ; //
function calling
getch ();
}
void sum ( ) // function definition
{
Int a , b, c;
printf( “ enter the two no
“);
scanf(“%d %d”,&a &b);
c=a+b;
printf (“sum is %d “, c);
}
Formal arguments formal arguments are those argument
which are declared at
function declaration and function definition ..For eg
void
sum ( int a , int b);
Actual arguments :-- These
are those arguments which are passed to function at calling time . For eg
Sum (3, 5);








0 comments:
Post a Comment