0

Hi everyone. I wrote the following code:

if the number entered is even ie if n=6 , the column of # should be at the 3rd column (ie 6/2)

if the number is odd ie if the number is 9, then the column of # should be at the 5th column

This the code I have to far: However, it prints the column of # always on the first column, so not in the middle as needed. Any help would be greatly appreciated! Thanks.

```
#include <stdio.h>
int main(int argc,char *argv[]) {
char letterI[100][100];
int n;
int retVal;
int i=0;
int j=0;
int middleI;
printf("Enter a number: ");
retVal = scanf("%d", &n);
if (retVal == 1) {
for (j=0; j<n-1; j++) {
letterI[0][j] = '#';
printf("%c", letterI[0][j]);
}
if (n%2!=0) {
for (i=0; i<n-1; i++) {
middleI = n/2 + 1;
letterI[middleI][i] = '#';
printf("%c\n", letterI[middleI][i]);
}
}
else if (n%2==0) {
for (i=0; i<n-1; i++) {
middleI = n/2 - 1;
letterI[middleI][i] = '#';
printf("%c\n", letterI[middleI][i]);
}
}
for (j=0; j<n; j++) {
letterI[n-1][j] = '#';
printf("%c", letterI[n-1][j]);
}
printf("\n");
} else {
printf("error");
}
return 0;
}
```