Monday, August 26, 2019

WAP ton display Floyd's Triangle.

//Program
1
2  3
4  5  6
7  8   9  10

#include<stdio.h>
void main()
{
    clrscr();
    int i,j,n,a;
    a=1;
    printf("Enter any number:");
    scanf("%d", &n);
    for( i=1 ; i<=n ; i++)
    {
         for( j=1 ; j<=i ; j++)
         {
              printf("%d",a);
              printf("  ");
              a=a+1;
         }
         printf("\n");
    }
    getch();
}

Output:
Enter any number:4
1
2  3
4  5  6
7  8  9  10
    

No comments:

Post a Comment

Write a program to find gcd of two numbers using recursion.

About:  The process in which a function calls itself is called recursion and the corresponding function is called as recursive function. ...