Q.) Write a C-program to print Floyd's Triangle .
or
How to print Floyd's Triangle in C.
Sol)
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,r,k=1 ;
printf("Enter the range : ") ;
scanf("%d",&r) ;
printf("FLOYD's TRIANGLE \n\n") ;
for(i=1;i<=r;i++)
{
for(j=1;j<=i;j++,k++)
printf("%d",k) ;
printf("\n") ;
}
return 0 ;
}
No comments:
Post a Comment