#include
int main(void)
{
int i, n, odd, square;
printf("This program prints squares using an odd method.\n");
printf("Enter number of entries in table: ");
scanf("%d", &n);
i = 1;
odd = 3;
/* Notice we initialize one variable (square), test another variable (i),
but increment a third variable (odd), where "i" is the number
to be squared, "square" is the squre of i, and "odd" is the odd number
that must be added to the current square to get the next square.
This allows the program to compute consecutive squares without
performing any multiplications. However, do not misuse flexibility
provided by for-loop. */
for (square = 1; i <= n; odd = odd + 2) {
printf("%10d%10d\n", i, square);
i++;
square = square + odd;
}
return 0;
}