Pages

Sunday, 20 May 2012

program to print a triangle


66./*Write a program to print a triangle.*/ 
#include<stdio.h>
#include<conio.h>
main()
{
int num,i,j,k,l;
clrscr();
printf("Enter The Number:");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
for(j=1;j<=num;j++)
{
printf("");
}
for(k=1;k<=i;k++)
{
printf("*");
}
for(l=1;l<i;l++)
{
printf("*");
}
printf("\n");
}
getch();
}

OUTPUT
            Enter The Number: 5
            *
            ***
            *****
            *******
            *********

No comments:

Post a Comment