Code:
for (row=1;row<=h;row++)
{
for (col=1;col<=h;col++)
{
if(col<=row)
{
printf (" ");
}
else
{
printf ("*");
}
}
printf ("\n");
}
That is what I have come up with to make the first pattern, but it is missing one line.
OK, I am needing to create the program I attached. So far I have
Code:
#include <stdio.h>
int main()
{
//variable declarations
int h, w;
int row, col;
//getting the height and a validation loop
printf("Enter the height [between 4 and 13(inclusive): ");
scanf("%d",&h);
while(h<4|| h>13)
{
printf("Error: The height should be between 4 and 13(inclusive) \n");
printf("Re-Enter the height: ");
scanf("%d",&h);
}
//getting the width and a validation loop
printf("Enter the width [between 3 and 10(inclusive): ");
scanf("%d",&w);
while(w<3 || w>10)
{
printf("Error: The width should be between 3 and 10(inclusive) ");
printf("Re-Enter the width: ");
scanf("%d",&w);
}
for (row=1;row<=h;row++)
{
for (col=1;col<=h;col++)
{
if(col<=row)
{
printf (" ");
}
else
{
printf ("*");
}
}
printf ("\n");
}
//Exit program
return 0;
}