A function definition Syntax:
return-type function-name(parameter declarations, if any)
{
declarations
statements
}
Example:
/*
power.c: This program will give you brief idea about functions.
Author: Afiz S
Date: 11/08/10
*/
#include
int power(int a, int b); //prototype of the function.
main()
{
int a,b;
printf("Enter your 2 number base and exponent\n");
scanf("%d%d",&a,&b);
printf("%dpower %d is = %d\n",a,b,power(a,b)); // calling function.
}
int power(int a, int b) // function defination
{
int i,base=a;
for(i=1;i
{
//printf("%d\n",a);
a=a*base;
}
return a;
}