Program that creates a parallelogram?
Hello,
I need help with figuring out how to create a program that creates a parallelogram made out of star characters (such as:'*'). This program is suppose to test my 'loop' skills.
The program is suppose to ask the user the height and width of the parallelogram and then display the parallelogram on the screen.
Right now, the program is displaying a square but NOT a parallelogram. I am having trouble with incorporating spaces into my loop.
For example: If I wanted to create a loop that simply prints out the letter: X with no spaces then creates a new line, then prints out X again with ONE space, then creates a new line, then prints out the letter X again with TWO spaces, then three spaces, then four, etc.....
Can someone please help?
Code:
int main () {
int z, i, n, height, width;
printf("Please enter the height of the parallelogram.\n");
scanf("%d", &height);
printf("Please enter the width of the parallelogram.\n");
scanf("%d", &width);
printf("\n\n\n");
for(i=0; i < height; i++){
for(n=1; n < width; n++)
printf("*");
printf("*");
printf("\n");
}