/* forloops.c
This program uses for loops to print a pretty square checkerboard of
the desired size to the screen.
This program may not reflect all the requirements of the C Coding
Standards used in this class.
*/
#include
int main() {
int i, j, size;
printf("Please enter the size of your checkerboard (integer): ");
scanf("%d", &size);
printf(" ");
for(i = 0; i < size; i++) {
printf("-");
} printf("\n");
for(i = size; i > 0; i--) {
printf("|");
for(j = 0; j < size; j++) {
if((i + j) % 2 == 0) {
printf("*");
} else {
printf(" ");
}
}
printf("|\n");
}
printf(" ");
for(i = 0; i < size; i++) {
printf("-");
} printf("\n");
return(0);
}