Write a program to print the following triangle for n lines.
*
* *
* * *
* * * *
* *
* * *
* * * *
#include<stdio.h>
#include<conio.h>
main()
{
int number,i,j;
clrscr();
printf("\n Enter Number : ");
scanf("%d", &number);
printf("\n\n");
for(i=1; i<=number; i++)
{
for(j = (number - 1);j>=i;j--)
printf(" ");
for(j=1;j<=i;j++)
printf("* ");
for(j = (number - 1);j>=i;j--)
printf(" ");
printf("\n");
}
getch();
}
#include<conio.h>
main()
{
int number,i,j;
clrscr();
printf("\n Enter Number : ");
scanf("%d", &number);
printf("\n\n");
for(i=1; i<=number; i++)
{
for(j = (number - 1);j>=i;j--)
printf(" ");
for(j=1;j<=i;j++)
printf("* ");
for(j = (number - 1);j>=i;j--)
printf(" ");
printf("\n");
}
getch();
}
0 Comments