Write a program to generate following triangle up to n lines. A B C D E F

an anonymous user · November 25, 2022
#include <stdio.h>

void main()
{
    int i, j, lines, n=0;
    
    printf ("enter number of lines:");
    scanf("%d",&lines);
    
    for (i=1;i<=lines;i++)
{ 
    for(j=lines;j>=i;j--)
    {
        printf("%c",'A'+n);
        n++;
    }
    printf("\n");
  }
}
Output
(Run the program to view its output)

Comments

Please sign up or log in to contribute to the discussion.