Problem 66. C Program to print the floyd’s triangle.
#include<stdio.h>
#include<conio.h>
main( )
{
int i,n,s,r k=1;
clrscr( );
printf(“enter a number of rows”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
for(s=1;s<=40-i;s++)printf(“ ”);
for(j=1;j<=i;j++)
printf(“%3d”,k++);
printf(“n”);
}
getch( );
}
C compiler: gcc 4.1.2
Back to main directory: Sample C Program | Software Practical | Solved C Assignment#include<stdio.h>
#include<conio.h>
main( )
{
int i,n,s,r k=1;
clrscr( );
printf(“enter a number of rows”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
for(s=1;s<=40-i;s++)printf(“ ”);
for(j=1;j<=i;j++)
printf(“%3d”,k++);
printf(“n”);
}
getch( );
}
C compiler: gcc 4.1.2