******************** ******************** ******************** ******************** ********************
/**
* C program to print rectangle star pattern
*/
#include <stdio.h>
int main()
{
int i, j, rows, columns;
/* Input rows and columns from user */
printf("Enter number of rows: ");
scanf("%d", &rows);
printf("Enter number of columns: ");
scanf("%d", &columns);
/* Iterate through each row */
for(i=1; i<=rows; i++)
{
/* Iterate through each column */
for(j=1; j<=columns; j++)
{
/* For each column print star */
printf("*");
}
/* Move to the next line/row */
printf("\n");
}
return 0;
}
Enter number of rows: 5
Enter number of columns: 10
**********
**********
**********
**********
**********
Step by step descriptive logic to print rectangle star pattern.
for(i=1; i<=rows; i++).for(j=1; j<=columns; j++).First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.