Pages

Sunday, 20 May 2012

program to print a triangle given value by user


70./*Write a program to print a triangle given value by user.*/


#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,l,n;
clrscr();
printf("Enter any value");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
for(j=1;j<=n-i;j++)
{
printf(" ");
}
for(k=1;k<=i;k++)
{
 printf("*");
}
for(l=1;l<i;l++)
{
printf("*");
}
printf("\n");
}
getch();
}


OUTPUT


            Enter any value: 5


                   *
                 ***
               *****
              *******
            *********     

No comments:

Post a Comment