What is the C program codings for printing triangle?

Answer:
#include

#include

main()

{

int i,i=50,r=60;

clrscr();

for(i=0;i<5;i++)

{

gotoxy(c,r);

for(j=0;j<1;j++)

{

printf("* ");

}

c-=2;

r+=2;

}

getch();

}

NEW METHOD WITHOUT GRAPHICS...

#include<stdio.h>

#include<conio.h>

main()
{
int row,i,n,star=1;
clrscr();
printf("Enter the no. of rows u want ");
scanf("%d",&n);
for(row=n;row>0;row--)
{
for(i=1;i<row-1;i++)
{
printf(" ");
}
for(i=1;i<=star;i++)
{
printf("*");
}
star=star+2;
printf("\n");
}
getch();
}

Note: There are comments associated with this question. See the discussion page to add to the conversation.
First answer by ID1975874143. Last edit by Deepshikha jindal. Contributor trust: 0 [recommend contributor recommended]. Question popularity: 1 [recommend question].