Pages

Thursday, September 29, 2016

C program to print Standing Triangle pattern.

C program to print standing triangle pattern. For n = 3, generate pattern as shown below:

*
* *
* * *
* *
*

#include<stdio.h>
int main()
{
     int i, j, N=5;
     for(i=0; i<N; i++)  
     {
           for(j=0; j<=i; j++)
                printf("* ");
           printf("\n");       
     }
     for(i=0; i<N; i++)  
     {
           for(j=N-1; j>i; j--)
                printf("* ");
           printf("\n");       
     }
     return 0;
}


Output of the Program:

*
* *
* * *
* *
*



1 comment:

  1. Thanks .. Here is a set of C star pattern programs for triangle, pyramids, number pattern etc.

    ReplyDelete