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

Hi, i need to write a program that adds a box to a grid in C, this is the code i

ID: 3828520 • Letter: H

Question

Hi, i need to write a program that adds a box to a grid in C, this is the code i have so far, but i cant make it work. it wont compile and says it needs more arguments.

#define NRows 21   // Dimensions for grid
#define NCols 51

char string1[21]; //length

char string2[51]; //width
char string3['/n']; //length
char string4['/n']; //width
int height=21; //the grid height
int width=51; //the grid width
int i; //control for grid width loop
int j; //control for grid height loop

void addBox(char grid[][NCols], int x, int y, int width, int height) {
   printf("Please enter the deminsions of the box ");
   scanf("%d %d", &x,&y);
   string3[x];
   string4[y];
}

#define NRows 21   // Dimensions for grid
#define NCols 51

char string1[21]; //length

char string2[51]; //width
char string3['/n']; //length
char string4['/n']; //width
int height=21; //the grid height
int width=51; //the grid width
int i; //control for grid width loop
int j; //control for grid height loop

void addBox(char grid[][NCols], int x, int y, int width, int height) {
   printf("Please enter the deminsions of the box ");
   scanf("%d %d", &x,&y);
   string3[x];
   string4[y];
}

Explanation / Answer

1)Please provide the function definition 2)Try to call addBox function from inside the ,mail.

Please check sample program below:-

#include <stdio.h>

#define NRows 21 // Dimensions for grid
#define NCols 51
void addBox(char[NRows][NCols], int ,int , int, int);
char string1[21]; //length
char string2[51]; //width
char string3['/n']; //length
char string4['/n']; //width
int height=21; //the grid height
int width=51; //the grid width
int i; //control for grid width loop
int j; //control for grid height loop

int main(void) {

char grid[NRows][NCols];
addBox( grid, 0, 0, width, height);// Passed 0,0 as later x and y are received as input from user inside function.
return 0;
}
void addBox(char grid[][NCols], int x, int y, int width, int height) {
printf("Please enter the deminsions of the box ");
scanf("%d %d", &x,&y);
string3[x];
string4[y]; //Add your remaining code below

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote