I've been trying to solve this problem all day. I can't figure out what I am supposed to do. I really hope you can help me and soon. Thank you for any contribution you can make.
Problem:
With a prompted height and width, I need to have a checkerboard of the given height and width with squares of X's and spaces that are 2x2. If either of the inputs are odd then the far right or bottom part of the board should be cut off.
Ex: 9 9 input should output:
XX XX XXX XX X XX XX XX XX XX XX XXX XX X XX XX XX XX XX XX X
This is my code so far:
Code:
#include <stdio.h>
int main () {
int height, width, row, col;
printf("Enter a height and a width: ");
scanf("%d%d", &height, &width);
for (row = 0; row < height/4; row++) {
for (col = 0; col < width/4; col++) {
printf("XX");
printf(" ");
}
printf("\n");
for (col = 0; col < width/4; col++) {
printf("XX");
printf(" ");
}
printf("\n");
for (col = 0; col < width/4; col++) {
printf(" ");
printf("XX");
}
printf("\n");
for (col = 0; col < width/4; col++) {
printf(" ");
printf("XX");
}
printf("\n");
}
if (height % 3 == 1); {
for (col = 0; col < width / 4; col++) {
printf("XX");
printf(" ");
}
printf("\n");
}
}
I need it to be under 400 characters. Thank you!!