Ok here is my exercise ive wrote code that doesn't work prints a square on the screen but not as the patren described below
Exercise 1: Display a Square Learning Objectives: To verify data entry, use while loops, and use ifstatements.Read This First You should have already read up on ‘while’ loops in your text. You are expected to use this command to display the box. You are alsoexpected to use only a single ‘if-else’ command when displaying the box (this will require a bit of thought). Do NOT use ‘for’ loops.What To Do Write a program (square.c) that reads in the size of the square and prints a hollow square of that size using asterisks and blanks. Your program must make a decision of whether to print a '*' or ' ' at aparticular location. Keep in mind that, using the DOS window, the output can only be displayed from left to right and (when you reachthe end of a line) from top to bottom. Your program should onlyaccept and work only for even side sizes between 2 and 20. Forexample, if your program reads in a size of 5, the following outputwould be displayed:
*****
* *
* *
* *
*****
ok here is my bad code
Code:
#include <stdio.h>
/* function main begins program execution */
int main()
{
int row; /* initialize row */
int column; /* define column */
int x;
printf( "Enter a number of row to be printed\n" );
scanf ( "%d", &x );
row = x;
while ( row >= 1 ) { /* loop until row < 1 */
column = 1; /* set column to 1 as interation begins */
while ( column <= row ) { /* loop times */
printf("%s", row ? "*" : "*"); /* output */
column++;/* increment column */
}
printf( "\n" ); /* begin new output line */
x--;
if ( x < 1 ) break;
} /* end outer while */
return 0; /* indicate program ended successfully */
} /* end function main */
any help or point into the right direction would be wounderful I'm about to pull my hair out on this one.
joe