Sunday, May 8, 2011

Write C Program to Print a Triangle

#include<stdio.h>

#include<conio.h>

void main()

{

int n;

printf("enter the lines :");

scanf("%d",&n);

for(int i=1;i<=n/2;i++)

{

printf("*\n");

for(int j=1;j<=2*i;j++)

printf("%d",j);

printf("\n");

}

if(n%2!=0)

printf("\n*");

getch();

}

No comments:

Post a Comment