Program in C to print different types of pattern
Program in C to print different types of pattern
For printing this type structure in C:
* * * * *
* * * *
* * *
* *
*
Here as we seen the figure is in row and column form thus we have to declare two variable ( i and j ) for row and column respectively. Here we use for loop statement of c.
/* program to print structure */
#include<stdio.h>
void main()
{
int i,j,n ;
clrscr () ;
printf ("\n Enter number of rows:") ;
scanf ("%d", &n) ;
for (i=1;i<=n;i++)
{
for (j=1;j<=n;j++)
{
if (i<=j)
printf ("*") ;
else
printf (" ") ;
}
printf ("\n") ;
}
getch () ;
}
Output screen ::
Enter number of rows :: 5
output ::
* * * * *
* * * *
* * *
* *
*
Comments
Post a Comment
Thank You for your participation..