/* * SelfTest1.4.c * Chapter 7 * By John Stile * Purpose: * Write a program using for loop and * the variables xx and xsqr to print * the squares of the integers from 1 to 7. * The following output is expected. * 1 squared equals 1 * 2 squared equals 4 * ... * 7 squared equals 49 */ #include #define NUM 7 int main(void) { int xx,xsqr; // declare int variables xx and yy for ( xx=1; xx<=NUM; xx=xx+1 ) { xsqr=(xx*xx); printf("%d squared equals %d\n", xx, xsqr); } return 0; }