PROGRAM TO PRINT THE PATTERN (Square *)

Best News | Quiz |Entertainment|Sports and Much more

PROGRAM TO PRINT THE PATTERN (Square *)

/* PROGRAM TO PRINT THE PATTERN
* * * * * * *
* *
* *
* *
* * * * * * *
*/

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j,n,k;
clrscr();
printf(“\n\nENTER HOW MANY ROWS : “);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
if(i==1)
{
for(j=1;j<=n+2;j++)
{
printf(““);

} } else if(i==n) { printf(“\n”); for(j=1;j<=n+2;j++) { printf(““);
}
}
else
{
for(j=1;j<=i-1;j++)
{
printf(“\n“); for(k=1;k<=n;k++) { printf(” “); } printf(““);
}
}
}
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!