Saturday, May 21, 2011

C program with user defined functions

/*Code a program to accept an integer value. Pass this value to
two functions - one to compute square value, and the other to
compute cube value. Print the results from the functions.*/

int square(int);
int cube(int);

int main()
int a;
printf("Enter a number :");
int b=square(a);
printf("\nSquare= %d",b);
printf("\nCube= %d",b);

int square(int x)
return x*x;

int cube(int x)
return x*x*x;

No comments:

Post a Comment

Google+ Followers