Write a program to print the following triangle for n lines : GTU Nov-Dec 2010

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();
}

Post a Comment

0 Comments