C Program to display the Floyd's triangle.



#include<stdio.h>
#include<conio.h>
void space(int i)
{      
while(i>=0)
{
printf(" ");
i--;
}
}
void floyd (int n)
{
int i,x=1,num=1;
while(n>0)
{
if(num>9)
space(n-2);
else
space(n);
for(i=0;i<x;i++)
printf(" %d",num++);
x++;
printf("\n");
n--;
}
}
void main()
{
clrscr();
floyd(13);
getch();
}

Algorithm
space(i)
step 1: start
step 2: check whether i>=0,then go to step 3
else go to step 5
step 3: print  " "
step 4: i=i-1
step 5: stop
floyd(n)
step 1: start
step 2: intilize x<-1,num<-1
step 3: check whether n>0 then go to step4
else go to step16
step 4: check whether num>9 then go to step5
else  go to step 6
step 5: call space(n-2)
step 6: call space(n)
step 7: intilize i<-0
step 8: check whether i<x then go to step9
else go to step 13
step 9: print num
step 10: num=num+1
step 11: i=i+1
step 12: go to step 8
step 13: x=x+1
step 14: go to new line
step 15: n=n-1
step 16: stop

main()
step 1:start
step 2: call floyd(13)
step 3: stop