Sunday, September 4, 2016

C program to print pattern.


/*C program to print following pattern. 

For n=4,

1
1 1
1 1 1
1 1 1 1
*/

#include<stdio.h>
int main()
{
     int i, j, n;
     printf("Enter your number:");
     scanf("%d", &n);
     for (i=0; i<n; i++)
     {
           for(j=0; j<=i; j++)
                printf("1 ");
           printf("\n");  
     }
     return 0; 
}


Output of the Program:

Enter your number:4
1
1 1
1 1 1
1 1 1 1



No comments:

Post a Comment