Wednesday, 20 August 2014

Filled Under: ,

C program to print triangle pyramid

Share

In c we can print various shape.The program which is written below print the right angle triangle pyramid using a special character  *.

#include<stdio.h>
int main()
{
int num, r = 1, i, s;
 printf("Enter number of rows : n");
 scanf("%d", &num);
 for (; num >= 1; num--, r++)
 {
 for (s = r; s > 1; s--)
 {
 printf("t");
 }
 for (i = 1; i <= num; i++)
 {
 printf("*t");// for lefting one tab
 }
 printf("n");
 }
 return 0;
}
Output: