Program to print triangle Pattern using numbers (◣) in using alphabets in continues manner for n number of lines.[Pattern:6]| Using C language| C Program series 27|
👨💻Program to print triangle Pattern using numbers (◣) in using alphabets in continues manner for n number of lines.[Pattern:6]
Code :
For n number of LINES:
/*
Program to print triangle (Pattern:6) using alphabets in continues manner for n number of lines.
For Example:n=5
A
BC
DEF
GHIJ
KLMNO
*/
#include<stdio.h>
main()
{
printf("Program to print triangle (Pattern:6) using alphabets for n number of lines.\n\n");
int i,j,n,k=65;
//Here,
//k for normal integer which used to variable to increment continuously
//n for number
//i for row
//j for colomn
printf("Enter the number:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=i;j>0;j--,k++)
{
if(k>90)//where, Ascii value of 90 is 'Z' So, if k>90 then again star from 'A' by setting value of k=65.
{
k=65;
}
printf("%c",k);
}
printf("\n");
}
}
The output of Code:
Comments
Post a Comment