March 10, 2008 at 9:04 pm
#3290
yeswanth
Participant
Write a program to print a triangle (Floyd Triangle) like the following: –
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <stdio.h><br /> #include <conio.h><br /> void main()<br /> {<br /> int num,i,j,k,s=40;<br /> clrscr();<br /> printf("nENTER THE NUMBER OF LINES: ");<br /> scanf("%d",&num);<br /> for(i=1;i<=num;i++)<br /> {<br /> for(j=1;j<=s;j++)<br /> printf(" ");<br /> for(k=1;k<=i;k++)<br /> printf("%d",k);<br /> for(k=i-1;k>0;k--)<br /> printf("%d",k);<br /> printf("n");<br /> s--;<br /> }<br /> getch();<br /> } |