- Function prototype--(declare before main function)
syntax:
return type function name(parameter list);
example:
void showmsg();
int add(int ,int);
- Function defination-(declare outside main)
syntax:
return type function_name(parameter list)
{
/*function body
}
example:
void showmsg()
{
printf("welcome");
}
or
int add(int x,int y)
{
int z;
z=x+y;
return(z);
}
- Function call--(used inside any function)
syntax:
function_name(parameter list);
When function does not any value that is if return_type is void the function call will be like this-
function_name(parameters);
example:
showmsg();
If returns type of function is other than void then function call will be like this-
syntax:
variable=function_name(parameters);
example:
int sum;
sum=add(10,20);
program using function
#include
#include
void message(); //function prototype
void main()
{
clrscr();
message(); //function call
printf("\nback in main");
getch();
}
void message() //function defination
{
printf("good morning");
}
O/P=good morning
back in main