Sunday, 16 April 2017

Program to print pattern using for loop

Program to print pattern using for loop

*
* *
* * *
* * * *

#include<stdio.h>
void main()
{
                int row,i,j;
                printf("Enter the number of rows you want: ");
                scanf("%d",&row);
               
                for(i=1;i<=row;i++)
                {
                                for(j=1;j<=i;j++)
                                {
                                                printf("* ");
                                }
                                printf("\n");
                }             
}



Enter the number of rows you want: 5

*
* *
* * *
* * * *
* * * * *