Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help writing a function in c computer language. the function needs to be

ID: 3652015 • Letter: I

Question

I need help writing a function in c computer language.

the function needs to be a loop function. Prints a Checkerboard shape of cross signs (X) of the given size.
A checkerboard has an alternate X and empty space. For example:

drawCheckerboard(8);
Here 8 means a checkerboard of 8 by 8

This displays the following output:

X X X X
X X X X
X X X X
X X X X
X X X X
X X X X
X X X X
X X X X

So far this is what i have


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
void drawCheckerboard(int size);
int main(void)
{
int size=0;
printf("Ener the size of the Checkerboard ");
scanf("%d", &size);
drawCheckerboard(size); $
return EXIT_SUCCESS;
}
void drawCheckerboard(int size)
{
int i, j, k;
k=0;
for(i = 0; i<size; i++)
{
for(j = 0; j<size; j++)
{
if(k==0)
{
printf("X");
k=1;
}
else
{
if(k==1)
{
printf(" ");
k=0;
}
}
}
printf(" ");
}
}



The problem with mine is that it does not shift my checker board displays like this
x x x x
x x x x
x x x x
x x x x
x x x x
x x x x
x x x x
x x x x

please help me shift it over

Explanation / Answer

#include #include #include void drawCheckerboard(int size); int main(void) { int size=0; printf("Ener the size of the Checkerboard "); scanf("%d", &size); drawCheckerboard(size); return 0; } void drawCheckerboard(int size) { int i, j, k; k=0; if(size%2!=0) { for(i = 0; i