I have an assignment in which I am supposed to make write a program which writes a square to the screen this program is supposed to allow the user to choose character to use, width height and indentation.
I am able to do all except when it comes to the indentation. I am only succeeding in implemented the indentation for the first row of the square but not the other.
Please anyone...help will be apprecciated. See code below
#include <stdio.h>
#include <stdlib.h>
/* This program makes a square filled with the characters of choice*/
int main(int argc, char *argv[])
{
char symbol[2]; // takes care of the symbol to print figures.
char a[10]; // takes care of wolcome message name input which is later the greeting on the screen.
int height; // squares heigth
int width; // squares width
int row; // variable for rows
int column; // variable for columns
char c = ' '; /*this is not used but I think it could be used to do the same as I do without it - check commented function above*/
int desired_spacing; // holds desired spaces
int spacing; // just a variable used as a counter
printf("Enter a name with 10 characters: "); scanf("%s" ,a);
printf("Hello: %s\n",a);
printf("\nWelcome to the tester!!!");
printf("\n-----------------------\n");
// Here can choose symbol
printf("\nplease enter a symbol to use: "); scanf("%s",symbol);
// Here can choose number of spaces
printf("\nplease enter desired spacing: "); scanf("%d" ,&desired_spacing);
// Here can choose width
printf("\nplease enter desired width: "); scanf("%d", &width);
// Here can choose heigth
printf("\nplease enter desired heigth: "); scanf("%d", &height);
// HERE BELOW COMES THE TROUBLE
for(spacing = 1; spacing <=desired_spacing; spacing++) /* the actual blank --- HERE IS WHAT I WANT TO DO WITH ALL THE ROWS. I CAN ONLY ACHIEVE IT WITH THE FIRST ROW*/
printf(" ");
{
for(row=0; row<width; row++) // row
printf("%s",symbol);
}
for(column=1; column<=height-1; column++) //column
{
printf(" ");
printf("\n");
for(row=0; row<=width-1; row++) //row
printf("%s",symbol);
}
system("PAUSE");
return 0;
}
Edited by Jaan, 26 March 2009 - 08:37 AM.
Please use code tags when you're posting your codes!


Sign In
Create Account

Back to top









