// This program is intended for debugging
// It doesn't compile first go, it needs a bit of attention
// This is code intended to loop
// Each time it loops, it will draw a square of asterisks
// that is sized based on the user input
#include <stdio.h>
int main (void) {
int exit = 0;
while (exit == 0) {
// Let the user choose the grid size
printf("Please enter the size of grid you would like me to make.\n");
printf("If you would like to exit, please type 0.\n");
int gridSize = 0;
scanf("%d", &gridSize);
// if my user gives me 0, exit the loop
if(gridSize == 0) {
exit = 1;
}
// loop through the rows of the grid
int y = 0; // y coordinate of the grid
while (y < gridSize) {
//printf("Starting y loop. y is %d.\n", y);
// For each row, loop through the columns
int x = 0; // x coordinate of the grid
while (x < gridSize) {
//printf("Starting x loop. x is %d.\n", x);
printf("*");
x = x + 1;
}
printf("\n"); // end the row, and start the next on a new line
y = y + 1;
}
}
printf("Thank you for using grid drawer. Have a nice day!\n");
return 0;
}
Resource created Tuesday 13 October 2020, 01:31:32 PM.
file: debugThis.c