Write a program that prints the following patterns separatel
Write a program that prints the following patterns separately one below the other. Use for loops to generate the patterns. All asterisks (*) should be printed by a single printf statement of the form printf (\"*\"): this causes the asterisks to print side by side).
Solution
main.c
#include <stdio.h>
int main()
{
int i, j, rows;
printf(\"Enter number of rows: \");
scanf(\"%d\",&rows);
for(i=1; i<=rows; ++i)
{
for(j=1; j<=i; ++j)
{
printf(\"* \");
}
printf(\"\ \");
}
for(i=1; i<=rows; ++i)
{
for(j=1; j<=i; ++j)
{
printf(\"* \");
}
printf(\"\ \");
}
return 0;
}
Output :
