Thursday, July 9, 2009

Give me an example of user define function in C language please?

A user defined funtion is one that has a proper signature i.e. name, return type (optional in some cases) and arguments e.g.





//function declaration, can optionally be written outside


//the 'main' function


bool myFunction(int x, int y);





//the funtion returns true if y is divisible by x,


//otherwise it returns false


bool myFunction(int x, int y)


{


if(x%y == 0)


return true;


else


return false;


}


No comments:

Post a Comment