
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
Program for triangular patterns of alphabets in C
Given a number n, the task is to print the triangular patterns of alphabets of the length n. First print the n characters then decrement one from the beginning in each line.
The triangular pattern of alphabet will be like in the given figure below −
Input − n = 5
Output
Input − n = 3
Output
Approach used below is as follows to solve the problem
Take input n and loop i from 1 to n.
For every i iterate j from i to n for every j print a character subtract 1 and add the value of j to ‘A’ .
Algorithm
Start In function int pattern( int n) Step 1→ Declare int i, j Step 2→ Loop For i = 1 and i < n and i++ Loop For j = i and j <= n and j++ Print 'A' - 1 + j Print new line In function int main() Step 1→ Declare and initialize n = 5 Step 2→ call pattern(n) Stop
Example
#include <stdio.h> int pattern( int n){ int i, j; for (i = 1; i <= n; i++) { for (j = i; j <= n; j++) { printf("%c", 'A' - 1 + j); } printf("
"); } return 0; } int main(){ int n = 5; pattern(n); return 0; }
Output
If run the above code it will generate the following output −
- Related Articles
- C/C++ Program for Triangular Matchstick Number?
- C/C++ Program for the Triangular Matchstick Number?
- C++ Program for triangular pattern (mirror image around 0)
- Python Program for Triangular Matchstick Number
- Program to print Lower triangular and Upper triangular matrix of an array in C
- C++ program to generate random alphabets
- C# Program to Illustrate Lower Triangular Matrix
- C# program to Illustrate Upper Triangular Matrix
- C program to represent the alphabets in spiral pattern
- Program to print right and left arrow patterns in C
- Program to print solid and hollow rhombus patterns in C
- Program to print solid and hollow square patterns in C
- Program to check if matrix is lower triangular in C++
- Program to check if matrix is upper triangular in C++
- C++ Program to Print the Multiplication Table in Triangular Form

Advertisements