C Program to Print Floyd Triangle

/*
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15 
 
 
*/
 
 
#include<stdio.h>
#include<conio.h>
void main()
{
    clrscr();
    int lines, i, j, k=1;
    printf("\n Enter the number of lines : ");
    scanf("%d",&lines);
    printf("\nFloyd's Triangle :\n");
    for(i=1; i<=lines; i++)
    {
        for(j=1; j<=i; j++)
        {
            printf("%d ",k);
            k++;
        }
        printf("\n");
    }
    getch();
}

Run:

No comments:

Post a Comment

100 C Programs with Code and Output

Program 1: C Program To Read Two Numbers And Print The Sum Of Given Two Numbers. Program 2: C Program To Read Three Numbers And Prin...