Program to use square() function and use it to print the squares of the numbers 1-10.



The squaring function is quite simple:

int square(int x)
{
return x * x;
}

Here is a loop and main program to call it:

#include

int square(int);

int main()
{
int i;

for(i = 1; i <= 10; i = i + 1)
printf("%d %d\n", i, square(i));
return 0;
}

No comments:

Post a Comment