Try out these absolute beginner level C Puzzles on loops:
Puzzle #1 : Generate a square block of stars with number of rows and columns given by user as shown below. Use only loops.
Example : 10×5 star matrix
**********
**********
**********
**********
**********
Puzzle #2 : Generate a triangle or wedge of stars with number stars in the last row given by user as shown below. Use only loops.
Example : 10 star wedge
*
**
***
****
*****
******
*******
********
*********
**********
Submit your answer in comments. Names of the people with unique correct answers will be featured on the post.






3 Comments
#include
#include
void main()
{
int i,j,row,col;
clrscr();
printf(“enter number of row and column:\n”);
scanf(“%d%d”,&row,&col);
for(i=1;i<=col;i )
{
for(j=1;j<=row;j )
{
printf("*");
}
printf("\n");
}
getch();
}
/*program to print a triangle block of stars where number of rows are user given*/
#include
#include
void main()
{
int i,j,row;
clrscr();
printf(“Enter number of rows:”);
scanf(“%d”,&row);
for(i=1;i<=row;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}
/*program to print a square block of stars where number of rows and number of columns are user given*/
#include
#include
void main()
{
int i,j,row,col;
clrscr();
printf(“Enter number of rows:”);
scanf(“%d”,&row);
printf(“Enter number of columns:”);
scanf(“%d”,&col);
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
printf("*");
}
printf("\n");
}
getch();
}