Print Rectangle Pattern of stars and numbers in C
Notes:
Print square and rectangle pattern of stars and numbers in C
Display square and rectangle pattern of stars and numbers in C
Ex1:
int row=0;
int totalRows=3;
int col=0;
int totalCols=3;
for(row=1; row<=totalRows; row++)
{
for(col=1; col<=totalCols;col++)
{
printf("* ");
}
printf("\n");
}
Output:
* * *
* * *
* * *
Ex 2:
int row=0;
int totalRows=3;
int col=0;
int totalCols=3;
for(row=1; row<=totalRows; row++)
{
for(col=1; col<=totalCols;col++)
{
printf("%d ",row);
}
printf("\n");
}
Output:
1 1 1
2 2 2
3 3 3
Ex 3:
int row=0;
int totalRows=3;
int col=0;
int totalCols=3;
for(row=1; row<=totalRows; row++)
{
for(col=1; col<=totalCols;col++)
{
printf("%d ",col);
}
printf("\n");
}
Output:
1 2 3
1 2 3
1 2 3