Alphabet Patterns  in Java, Python, and C programming

Learn how to code different alphabet patterns in Java, Python, and C programs.29 min


Alphabet-Patterns in c

1. Pattern: Right-Angle Alphabet Triangle

Expected output:

A
AB
ABC
ABCD
ABCDE

Easy Logic explanation:

  • First, iterate the loop over the given number of rows with the outer loop
  • For each and every row, we use an inner loop to print the characters starting from A and we will print them up to the current row number. (For example — For row1, print A ; Then for row2, print AB , and so on… up to our total number of rows)
  • Inner loop uses a char variable to print all required letters sequentially.

Solution in Java:

public class AlphabetPattern {
    public static void main(String[] args) {
        // Number of rows for the pattern
        int rows = 5;
        
        // Loop through each row
        for (int i = 1; i <= rows; i++) {
            // Loop to print letters in each row
            for (char ch = 'A'; ch < 'A' + i; ch++) {
                System.out.print(ch);  // Print each character
            }
            System.out.println();  // Move to the next line after each row
        }
    }
}

Solution in Python:

# Function to print the alphabet pattern
def print_alphabet_pattern(rows):
    # Loop through each row
    for i in range(1, rows + 1):
        # Loop to print letters in each row
        for ch in range(ord('A'), ord('A') + i):
            print(chr(ch), end='')  # Print each character without a newline
        print()  # Move to the next line after each row

# Define number of rows
rows = 5
# Call the function to print the pattern
print_alphabet_pattern(rows)

Solution in C program:

#include <stdio.h>

int main() {
    int rows = 5;  // Define number of rows for the pattern
    
    // Outer loop for each row
    for (int i = 1; i <= rows; i++) {
        // Inner loop to print characters in each row
        for (char ch = 'A'; ch < 'A' + i; ch++) {
            printf("%c", ch);  // Print each character
        }
        printf("n");  // Move to the next line after each row
    }
    
    return 0;
}

2. Pattern: Reverse Right-Angle Alphabet Triangle (Decreasing Pattern)

Expected output:

E
DD
CCC
BBBB
AAAAA

Easy explanation:

  • Use one outer loop, which will go from 5 to 1, as we want to print 5 rows with decreasing characters.
  • For each and every row, we determine the character that starts from E for the first row. Print it multiple times based on the row number.

Solution in Java:

public class ReverseAlphabetPattern {
    public static void main(String[] args) {
        // Number of rows for the pattern
        int rows = 5;
        
        // Loop through each row, starting from the last row to the first row
        for (int i = rows; i >= 1; i--) {
            // Loop to print the same character in each row
            for (char ch = (char) ('A' + i - 1); ch <= (char) ('A' + i - 1); ch++) {
                for (int j = 1; j <= i; j++) {
                    System.out.print(ch);  // Print the character 'i' times
                }
            }
            System.out.println();  // Move to the next line after each row
        }
    }
}

Solution in Python:

# Function to print the reverse alphabet pattern
def print_reverse_alphabet_pattern(rows):
    # Loop through each row, starting from the last row
    for i in range(rows, 0, -1):
        # Determine the character to print (starting from 'E')
        ch = chr(ord('A') + i - 1)
        # Print the character 'i' times
        print(ch * i)

# Define number of rows
rows = 5
# Call the function to print the pattern
print_reverse_alphabet_pattern(rows)

Solution in C Program:

#include <stdio.h>

int main() {
    int rows = 5;  // Define number of rows for the pattern
    
    // Outer loop for each row, starting from the last row
    for (int i = rows; i >= 1; i--) {
        // Determine the character to print (starting from 'E')
        char ch = 'A' + i - 1;
        
        // Inner loop to print the character 'i' times
        for (int j = 1; j <= i; j++) {
            printf("%c", ch);  // Print the character
        }
        printf("n");  // Move to the next line after each row
    }
    
    return 0;
}

3. Pattern: Right-Angle Alphabet Triangle (Increasing Repeated Pattern)

Expected output:

A
BB
CCC
DDDD
EEEEE

Simple Logic explanation:

  • Outerloop will control the number of rows; in our case, it is 5.
  • The inner loop will print the same character repeatedly in each row.
  • The character is determined by the row number that starts from A for the row 1, B for row 2, and so on…

Solution in Java:

public class IncreasingAlphabetPattern {
    public static void main(String[] args) {
        // Number of rows for the pattern
        int rows = 5;
        
        // Loop through each row
        for (int i = 1; i <= rows; i++) {
            // Loop to print the same character 'i' times
            for (int j = 1; j <= i; j++) {
                // Print the character corresponding to the row
                System.out.print((char) ('A' + i - 1));
            }
            System.out.println();  // Move to the next line after each row
        }
    }
}

Solution in Python:

# Function to print the increasing repeated alphabet pattern
def print_increasing_alphabet_pattern(rows):
    # Loop through each row
    for i in range(1, rows + 1):
        # Print the character 'i' times, corresponding to the row number
        print(chr(ord('A') + i - 1) * i)

# Define number of rows
rows = 5
# Call the function to print the pattern
print_increasing_alphabet_pattern(rows)

Solution in C Program:

#include <stdio.h>

int main() {
    int rows = 5;  // Define number of rows for the pattern
    
    // Outer loop for each row
    for (int i = 1; i <= rows; i++) {
        // Inner loop to print the character 'i' times
        for (int j = 1; j <= i; j++) {
            printf("%c", 'A' + i - 1);  // Print the character corresponding to the row
        }
        printf("n");  // Move to the next line after each row
    }
    
    return 0;
}

4. Pattern: Alphabet Reverse Triangle with Increasing Sequence

Expected output:

E
DE
CDE
BCDE
ABCDE

Solution in Java:

public class AlphabetPattern {
    public static void main(String[] args) {
        // Number of rows for the pattern
        int rows = 5;
        
        // Loop through each row
        for (int i = 0; i < rows; i++) {
            // Loop to print the characters for the current row
            for (char ch = (char) ('E' - i); ch <= 'E'; ch++) {
                System.out.print(ch);  // Print the character
            }
            System.out.println();  // Move to the next line after each row
        }
    }
}

Solution in Python:

# Function to print the alphabet pattern
def print_alphabet_pattern(rows):
    # Loop through each row
    for i in range(rows):
        # Print the characters for the current row
        for ch in range(ord('E') - i, ord('E') + 1):
            print(chr(ch), end='')  # Print the character without newline
        print()  # Move to the next line after each row

# Define number of rows
rows = 5
# Call the function to print the pattern
print_alphabet_pattern(rows)

Solution in C Program:

#include <stdio.h>

int main() {
    int rows = 5;  // Define number of rows for the pattern
    
    // Outer loop for each row
    for (int i = 0; i < rows; i++) {
        // Inner loop to print the characters for the current row
        for (char ch = 'E' - i; ch <= 'E'; ch++) {
            printf("%c", ch);  // Print the character
        }
        printf("n");  // Move to the next line after each row
    }
    
    return 0;
}

5. Pattern: Alphabet Triangle (Decreasing Sequence)

Expected output:

ABCDE
ABCD
ABC
AB
A

Solution in Java:

public class AlphabetPattern {
    public static void main(String[] args) {
        // Number of rows for the pattern
        int rows = 5;
        
        // Loop through each row
        for (int i = 0; i < rows; i++) {
            // Loop to print characters from 'A' to the current letter
            for (char ch = 'A'; ch < 'A' + (rows - i); ch++) {
                System.out.print(ch);  // Print each character
            }
            System.out.println();  // Move to the next line after each row
        }
    }
}

Solution in Python:

# Function to print the alphabet pattern
def print_alphabet_pattern(rows):
    # Loop through each row
    for i in range(rows):
        # Print characters from 'A' to the current letter
        print(''.join(chr(ord('A') + j) for j in range(rows - i)))

# Define number of rows
rows = 5
# Call the function to print the pattern
print_alphabet_pattern(rows)

Solution in C Program:

#include <stdio.h>

int main() {
    int rows = 5;  // Define number of rows for the pattern
    
    // Outer loop for each row
    for (int i = 0; i < rows; i++) {
        // Inner loop to print characters from 'A' to the current letter
        for (char ch = 'A'; ch < 'A' + (rows - i); ch++) {
            printf("%c", ch);  // Print the character
        }
        printf("n");  // Move to the next line after each row
    }
    
    return 0;
}

6. Pattern: Alphabet Right-Angle Triangle (Shifting Starting Letter)

Expected output:

ABCDE
BCDE
CDE
DE
E

Solution in Java:

public class AlphabetPattern {
    public static void main(String[] args) {
        // Number of rows for the pattern
        int rows = 5;
        
        // Loop through each row
        for (int i = 0; i < rows; i++) {
            // Loop to print characters from the current starting character
            for (char ch = (char) ('A' + i); ch <= 'E'; ch++) {
                System.out.print(ch);  // Print each character
            }
            System.out.println();  // Move to the next line after each row
        }
    }
}

Solution in Python:

# Function to print the alphabet pattern
def print_alphabet_pattern(rows):
    # Loop through each row
    for i in range(rows):
        # Print characters starting from 'A' + i to 'E'
        print(''.join(chr(ord('A') + j) for j in range(i, rows)))

# Define number of rows
rows = 5
# Call the function to print the pattern
print_alphabet_pattern(rows)

Solution in C Program:

#include <stdio.h>

int main() {
    int rows = 5;  // Define number of rows for the pattern
    
    // Outer loop for each row
    for (int i = 0; i < rows; i++) {
        // Inner loop to print characters starting from 'A' + i to 'E'
        for (char ch = 'A' + i; ch <= 'E'; ch++) {
            printf("%c", ch);  // Print each character
        }
        printf("n");  // Move to the next line after each row
    }
    
    return 0;
}

7. Pattern: Alphabet Triangle with Reversed Sequence

Expected output:

A
BA
CBA
DCBA
EDCBA

Solution in Java:

public class ReverseAlphabetPattern {
    public static void main(String[] args) {
        // Number of rows for the pattern
        int rows = 5;
        
        // Loop through each row
        for (int i = 0; i < rows; i++) {
            // Loop to print characters in reverse order for each row
            for (char ch = (char) ('A' + i); ch >= 'A'; ch--) {
                System.out.print(ch);  // Print each character in reverse order
            }
            System.out.println();  // Move to the next line after each row
        }
    }
}

Solution in Python:

# Function to print the alphabet pattern
def print_reverse_alphabet_pattern(rows):
    # Loop through each row
    for i in range(rows):
        # Print characters in reverse order from 'A' + i to 'A'
        print(''.join(chr(ord('A') + j) for j in range(i, -1, -1)))

# Define number of rows
rows = 5
# Call the function to print the pattern
print_reverse_alphabet_pattern(rows)

Solution in C Program:

#include <stdio.h>

int main() {
    int rows = 5;  // Define number of rows for the pattern
    
    // Outer loop for each row
    for (int i = 0; i < rows; i++) {
        // Inner loop to print characters in reverse order for each row
        for (char ch = 'A' + i; ch >= 'A'; ch--) {
            printf("%c", ch);  // Print each character
        }
        printf("n");  // Move to the next line after each row
    }
    
    return 0;
}

8. Pattern: Alphabet Triangle (Decreasing Characters)

Expected output:

AAAAA
BBBB
CCC
DD
E

Solution in Java:

public class DecreasingAlphabetPattern {
    public static void main(String[] args) {
        // Number of rows for the pattern
        int rows = 5;
        
        // Loop through each row
        for (int i = 0; i < rows; i++) {
            // Loop to print the same character for 'rows - i' times
            for (int j = 0; j < (rows - i); j++) {
                System.out.print((char) ('A' + i));  // Print the character for this row
            }
            System.out.println();  // Move to the next line after each row
        }
    }
}

Solution in Python:

# Function to print the decreasing alphabet pattern
def print_decreasing_alphabet_pattern(rows):
    # Loop through each row
    for i in range(rows):
        # Print the character 'rows - i' times
        print(chr(ord('A') + i) * (rows - i))

# Define number of rows
rows = 5
# Call the function to print the pattern
print_decreasing_alphabet_pattern(rows)

Solution in C Program:

#include <stdio.h>

int main() {
    int rows = 5;  // Define number of rows for the pattern
    
    // Outer loop for each row
    for (int i = 0; i < rows; i++) {
        // Inner loop to print the character 'rows - i' times
        for (int j = 0; j < (rows - i); j++) {
            printf("%c", 'A' + i);  // Print the character for this row
        }
        printf("n");  // Move to the next line after each row
    }
    
    return 0;
}

9. Pattern: Decreasing Alphabet Triangle (Reverse Order)

Expected output:

EEEEE
DDDD
CCC
BB
A

Solution in Java:

public class ReverseAlphabetPattern {
    public static void main(String[] args) {
        // Number of rows for the pattern
        int rows = 5;
        
        // Loop through each row
        for (int i = 0; i < rows; i++) {
            // Loop to print the same character for 'rows - i' times
            for (int j = 0; j < (rows - i); j++) {
                System.out.print((char) ('E' - i));  // Print the character for this row
            }
            System.out.println();  // Move to the next line after each row
        }
    }
}

Solution in Python:

# Function to print the decreasing alphabet pattern
def print_decreasing_alphabet_pattern(rows):
    # Loop through each row
    for i in range(rows):
        # Print the character 'rows - i' times
        print(chr(ord('E') - i) * (rows - i))

# Define number of rows
rows = 5
# Call the function to print the pattern
print_decreasing_alphabet_pattern(rows)

Solution in C Program:

#include <stdio.h>

int main() {
    int rows = 5;  // Define number of rows for the pattern
    
    // Outer loop for each row
    for (int i = 0; i < rows; i++) {
        // Inner loop to print the character 'rows - i' times
        for (int j = 0; j < (rows - i); j++) {
            printf("%c", 'E' - i);  // Print the character for this row
        }
        printf("n");  // Move to the next line after each row
    }
    
    return 0;
}

10. Pattern: Alphabet Reverse Sequence Triangle

Expected output:

E
ED
EDC
EDCB
EDCBA

Solution in Java:

public class ReverseSequencePattern {
    public static void main(String[] args) {
        // Number of rows for the pattern
        int rows = 5;
        
        // Loop through each row
        for (int i = 0; i < rows; i++) {
            // Loop to print characters from 'E' down to the appropriate letter
            for (char ch = 'E'; ch >= 'E' - i; ch--) {
                System.out.print(ch);  // Print each character
            }
            System.out.println();  // Move to the next line after each row
        }
    }
}

Solution in Python:

# Function to print the reverse sequence pattern
def print_reverse_sequence_pattern(rows):
    # Loop through each row
    for i in range(rows):
        # Print characters from 'E' down to the appropriate character
        print(''.join(chr(ord('E') - j) for j in range(i + 1)))

# Define number of rows
rows = 5
# Call the function to print the pattern
print_reverse_sequence_pattern(rows)

Solution in C Program:

#include <stdio.h>

int main() {
    int rows = 5;  // Define number of rows for the pattern
    
    // Outer loop for each row
    for (int i = 0; i < rows; i++) {
        // Inner loop to print characters from 'E' down to the current letter
        for (char ch = 'E'; ch >= 'E' - i; ch--) {
            printf("%c", ch);  // Print the character
        }
        printf("n");  // Move to the next line after each row
    }
    
    return 0;
}

11. Pattern: Reverse Alphabet Triangle

Expected output:

EDCBA
DCBA
CBA
BA
A

Solution in Java:

public class ReverseAlphabetTriangle {
    public static void main(String[] args) {
        // Number of rows for the pattern
        int rows = 5;
        
        // Loop through each row
        for (int i = 0; i < rows; i++) {
            // Loop to print characters from 'E' down to the appropriate letter
            for (char ch = (char) ('E' - i); ch >= 'A'; ch--) {
                System.out.print(ch);  // Print each character
            }
            System.out.println();  // Move to the next line after each row
        }
    }
}

Solution in Python:

# Function to print the reverse alphabet triangle pattern
def print_reverse_alphabet_triangle(rows):
    # Loop through each row
    for i in range(rows):
        # Print characters from 'E' - i down to 'A'
        print(''.join(chr(ord('E') - j) for j in range(i + 1)))

# Define number of rows
rows = 5
# Call the function to print the pattern
print_reverse_alphabet_triangle(rows)

Solution in C Program:

#include <stdio.h>

int main() {
    int rows = 5;  // Define number of rows for the pattern
    
    // Outer loop for each row
    for (int i = 0; i < rows; i++) {
        // Inner loop to print characters from 'E' - i down to 'A'
        for (char ch = 'E' - i; ch >= 'A'; ch--) {
            printf("%c", ch);  // Print each character
        }
        printf("n");  // Move to the next line after each row
    }
    
    return 0;
}

12. Pattern: Reverse Alphabet Triangle (Decreasing Length)

Expected output:

EDCBA
EDCB
EDC
ED
E

Solution in Java:

public class ReverseAlphabetTriangle {
    public static void main(String[] args) {
        // Number of rows for the pattern
        int rows = 5;
        
        // Loop through each row
        for (int i = 0; i < rows; i++) {
            // Loop to print characters starting from 'E' down to the appropriate letter
            for (char ch = 'E'; ch >= 'E' - i; ch--) {
                System.out.print(ch);  // Print each character
            }
            System.out.println();  // Move to the next line after each row
        }
    }
}

Solution in Python:

# Function to print the reverse alphabet triangle pattern
def print_reverse_alphabet_triangle(rows):
    # Loop through each row
    for i in range(rows):
        # Print characters starting from 'E' down to the appropriate letter
        print(''.join(chr(ord('E') - j) for j in range(i + 1)))

# Define number of rows
rows = 5
# Call the function to print the pattern
print_reverse_alphabet_triangle(rows)

Solution in C Program:

#include <stdio.h>

int main() {
    int rows = 5;  // Define number of rows for the pattern
    
    // Outer loop for each row
    for (int i = 0; i < rows; i++) {
        // Inner loop to print characters starting from 'E' down to the current letter
        for (char ch = 'E'; ch >= 'E' - i; ch--) {
            printf("%c", ch);  // Print each character
        }
        printf("n");  // Move to the next line after each row
    }
    
    return 0;
}

Conclusion:

Hopefully above Alphabet patterns fulfill your requirements, and trust me, it’s the base of your knowledge and how you are making inner-outer loops, how much time complexity it will take to optimize your logic, everything matters the most. If you are studying right now, I wish best of luck because it’s the main thing that will be helpful to you when you do your job.

Alphabet patterns in a C program are building your base knowledge for your career growth.

©️ 2025 – Alphabet patterns in Java, Python, and C program by Rakshit Shah (Author).

You may also like — Check Pair of Brackets exercise, which is mostly asked questions in interviews.

adsense


Discover more from 9Mood

Subscribe to get the latest posts sent to your email.


Like it? Share with your friends!

What's Your Reaction?

Lol Lol
0
Lol
WTF WTF
0
WTF
Cute Cute
0
Cute
Love Love
0
Love
Vomit Vomit
0
Vomit
Cry Cry
0
Cry
Wow Wow
0
Wow
Fail Fail
0
Fail
Angry Angry
0
Angry
Rakshit Shah

Legend

Hey Moodies, Kem chho ? - Majama? (Yeah, You guessed Right! I am from Gujarat, India) 25, Computer Engineer, Foodie, Gamer, Coder and may be a Traveller . > If I can’t, who else will? < You can reach out me by “Rakshitshah94” on 9MOodQuoraMediumGithubInstagramsnapchattwitter, Even you can also google it to see me. I am everywhere, But I am not God. Feel free to text me.

0 Comments

Leave a Reply

Choose A Format
Story
Formatted Text with Embeds and Visuals
List
The Classic Internet Listicles
Ranked List
Upvote or downvote to decide the best list item
Open List
Submit your own item and vote up for the best submission
Countdown
The Classic Internet Countdowns
Meme
Upload your own images to make custom memes
Poll
Voting to make decisions or determine opinions
Trivia quiz
Series of questions with right and wrong answers that intends to check knowledge
Personality quiz
Series of questions that intends to reveal something about the personality
is avocado good for breakfast? Sustainability Tips for Living Green Daily Photos Taken At Right Moment