Monday, August 26, 2019

WAP to display triangle.

//Program to display
A
A  B
A  B  C
A  B  C  D

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

Output:
Enter any number:4
A
A  B 
A  B  C
A  B  C  D

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. ...