pTutorial

New way to learn C programming

C program to print piramid pattren

This is a user define C program to print piramid pattren with the help of nested for loop and star as shown below.

C piramid pattren program

#include <stdio.h>
#include <conio.h>
void main()
{
   int row, c, n, u;
   printf("Please enter the number of row\n");
   scanf("%d",&n);
   u = n;
   for ( row = 1 ; row <= n ; row++ )
   {
      for ( c = 1 ; c < u ; c++ )
         printf(" ");
         u--;
      for ( c = 1 ; c <= 2*row - 1 ; c++ )
         printf("*");
        printf("\n");
   }
   getch();
}

Download piramid pattren

Output of program

See Also

Php static keyword   |   Php variable functions with examples pdf   |   Php variables

QUOTES OF THE DAY

Beauty is truth, Truth beauty- That is all

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER