Friday, May 3, 2019

Write a C program to print the Floyd Triangle.

program:

#include<stdio.h> 
main()
{
    int n,i,j,k;
    printf("enter a number:"); 
    scanf("%d",&n);
    k=1;
    for(j=1;j<=n;j++)
    {
        for(i=1;i<=j;i++)
        {
        printf(" %d ",k); k++;
        }
        printf("\n");
    }
}
output:-

No comments:

Post a Comment