Professional Documents
Culture Documents
(CS 101)
USING
Functions {C}
Programming
Why function ?
Avoids rewriting the same code over and over.
Using functions it becomes easier to write programs and keep track of what they doing.
void main()
{
....
func1(); Function call
}
void func1()
{
.... Function definition
//function body
....
}
Syntax Example
return-type function-name (arg-1, arg 2, …); void addition(int, int);
Syntax Example
return-type function-name (arg-1, arg 2, …) void addition(int x, int y)
{ {
//... Function body printf("Addition is=%d“,(x+y));
} }
Syntax
return;
Or
return (expression);
Output
Enter the number :7
The number 7 is a prime number.
Storage Initial
Storage Scope Life Example
Specifier Value
Automatic int a;
Stack Garbage Within block End of block
{auto} auto int a;
Till end of
Static Data Zero Within block static extern int var;
program
{static} segment static int var;
Thank you