Java Program to Print Right Angled Triangle with Row wise Increasing Character Pattern

Printing Right Angled Triangle with Row wise Increasing Character Pattern

In this program we are going to see how to print the right angled triangle with row wise increasing character pattern.

Example-1

When character=h 
and row value=3

h
h i
h i j
Example-2:

When character=A 
and row value=5

A
A B
A B C
A B C D
A B C D E

Now, let’s see the actual program to print it.

The best and excellent way to learn a java programming language is by practicing Simple Java Program Examples as it includes basic to advanced levels of concepts.

Approach:

  • Enter the character and store it in a variable c.
  • Then enter total row and store it in an integer variable row_count.
  • Take one outer for loop to iterate the rows.
  • Take one inner loop to iterate the columns and print the character.
  • After each iteration print a new line.

JAVA CODE:

import java.util.Scanner;
class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        //Taking character to be 
        //printed as input from the user
        System.out.print("Character : ");
        char c = scan.next().charAt(0);
    
        //Taking number of rows as input from the user
        System.out.print("Rows : ");
        int row_count = scan.nextInt();
    
        int row, col;
        //Converting the character to its ascii value
        int asciiValue = (int) c;
    
        //Checks whether the character is a letter or not
        if(asciiValue>=65&&asciiValue<=122)
        {
            
            //Outer loop to iterate rows
            for(row = 0; row<row_count; row++)
            {
                //Reseting the character after each iteration
                asciiValue = c;
                //Inner loop to iterate columns
                for(col = 0; col<row+1; col++)
                {
                    System.out.print((char)(asciiValue)+" ");
                    asciiValue++;
                }
                //Prints a newline
                System.out.println();
            }
        }
    }
}
Output:

Character : A
Rows : 5

A
A B
A B C
A B C D
A B C D E

C CODE:

#include <stdio.h>

int main()
{
    //Taking character to be printed as input from the user
    printf("Character : ");
    char c;
    scanf("%c", &c);

    //Taking number of rows as input from the user
    printf("Rows : ");
    int row_count;
    scanf("%d", &row_count);

    int row, col;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 0; row < row_count; row++)
        {
            //Reseting the character after each iteration;
            asciiValue = c;
            //Inner loop to iterate columns
            for (col = 0; col < row + 1; col++)
            {
                printf("%c ", (char)(asciiValue));
                asciiValue++;
            }
            //Prints a newline
            printf("\n");
        }
    }
    return 0;
}
Output:

Character : A
Rows : 5

A
A B
A B C
A B C D
A B C D E

C++ CODE:

#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    //Taking character to be printed as input from the user
    cout << "Character : ";
    char c;
    cin >> c;

    //Taking number of rows as input from the user
    cout << "Rows : ";
    int row_count;
    cin >> row_count;

    int row, col;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 0; row < row_count; row++)
        {
            //Reseting the character after each iteration
            asciiValue = c;
            //Inner loop to iterate columns
            for (col = 0; col < row + 1; col++)
            {
                cout << (char)asciiValue << " ";
                asciiValue++;
            }
            //Prints a newline
            cout << endl;
        }
    }
    return 0;
}

Output:

Character : A
Rows : 5

A
A B
A B C
A B C D
A B C D E

Related Java Star Pattern Programs:

Java Program to Print Alphabet A character Pattern

Program to Print Alphabet A character Pattern

In the previous article, we have discussed Java Program to Print Alphabet T Character Pattern

In this article we are going to see how to print the alphabet A character pattern.

Output:

Enter rows : 8

ABC 
A     D
A     D
ABCD
A     D
A     D
A     D

Interested in programming and want to excel in it by choosing the short ways. Then, practicing with the available Java Program list is mandatory.

Approach:

  • We will take the number of rows as 8 and store it in n.
  • First we will use a for loop to print the vertical lines
  • We are going to use the if..else condition to print the horizontal line.
  • After each iteration we will print a new line.

Java Code to Print Alphabet A character Pattern

import java.util.Scanner;
public class pattern  
{  
    public static void main(String[] args)  
    {  
        int ascii=65;
        Scanner scan = new Scanner(System.in);
        //Taking input as 8 for our A
        System.out.print("Enter rows : ");
        int r, c, rows= scan.nextInt();  
        // Outer for loop 
        for (r = 0; r<=rows; r++)   
        {  
        // Inner for loop 
        for (c = 0; c<= rows / 2; c++)   
        {  
            //To print the vertical lines 
            if ((c == 0 || c == rows / 2) && r != 0 ||  
            //Prints the first line 
            r == 0  && c != rows / 2 ||   
            //prints the middle line
            r == rows / 2)   
                System.out.print((char)(c+ascii));  
            else  
                System.out.print(" ");  
        }  
        //Prints new line
        System.out.println();  
        }  
    }  
}
Output:

Enter rows : 8

ABC 
A     D
A     D
ABCD
A     D
A     D
A     D

C Code to Print Alphabet A character Pattern

#include <stdio.h>
int main(int argc, char const *argv[])
{
    int ascii=65;
    int r, c, rows;
    //Taking row as input from user
    printf("Enter rows : ");
    scanf("%d", &rows);
    // Outer for loop
    for (r = 0; r <= rows; r++)
    {
        // Inner for loop
        for (c = 0; c <= rows / 2; c++)
        {
            //To print the vertical lines
            if ((c == 0 || c == rows / 2) && r != 0 ||
                //Prints the first line
                r == 0 && c != rows / 2 ||
                //prints the middle line
                r == rows / 2)
                printf("%c",(c+ascii));
            else
                printf(" ");
        }
        //Prints new line
        printf("\n");
    }
    return 0;
}
Output:

Enter rows : 8

ABC 
A     D
A     D
ABCD
A     D
A     D
A     D

C++ Code to Print Alphabet A character Pattern

#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    int ascii=65;
    int r, c, rows;
    //Taking row as input from user
    cout << "Enter rows : ";
    cin >> rows;
    // Outer for loop
    for (r = 0; r <= rows; r++)
    {
        // Inner for loop
        for (c = 0; c <= rows / 2; c++)
        {
            //To print the vertical lines
            if ((c == 0 || c == rows / 2) && r != 0 ||
                //Prints the first line
                r == 0 && c != rows / 2 ||
                //prints the middle line
                r == rows / 2)
                cout << (char)(c+ascii);
            else
                cout << " ";
        }
        //Prints new line
        cout << endl;
    }
    return 0;
}
Output:

Enter rows : 8

ABC 
A     D
A     D
ABCD
A     D
A     D
A     D

Are you seeking professional help for coding in the Java programming language? The tutorial of Java Programming Examples for beginners and experts will strongly improve your coding skills then you can program for any logic in Java.

Related Java Character Pattern Programs:

Java Program to Print Right Angled Triangle with Row wise Decreasing Character Pattern

Printing Right Angled Triangle with Row wise Decreasing Character Pattern

In this program we are going to see how to print the right angled triangle with row wise decreasing character pattern.

Example-1

When character=h 
and row value=3

h
h g
h g f
Example-2:

When character=A 
and row value=5

Z
Z X
Z X W
Z X W V
Z X W V U

Now, let’s see the actual program to print it.

Provided list of Simple Java Programs is specially designed for freshers and beginners to get familiarize with the concepts of Java programming language and become pro in coding.

Approach:

  • Enter the character and store it in a variable c.
  • Then enter total row and store it in an integer variable row_count.
  • Take one outer for loop to iterate the rows.
  • Take one inner loop to iterate the columns and print the character.
  • After each iteration print a new line.

JAVA CODE:

import java.util.Scanner;
class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        //Taking character to be printed as input from the user
        System.out.print("Character : ");
        char c = scan.next().charAt(0);
    
        //Taking number of rows as input from the user
        System.out.print("Rows : ");
        int row_count = scan.nextInt();
    
        int row, col;
        //Converting the character to its ascii value
        int asciiValue = (int) c;
    
        //Checks whether the character is a letter or not
        if(asciiValue>=65&&asciiValue<=122)
        {
            
            //Outer loop to iterate rows
            for(row = 0; row<row_count; row++)
            {
            //Reseting the character after each iteration
                asciiValue = c;
                //Inner loop to iterate columns
                for(col = 0; col<row+1; col++)
                {
                    System.out.print((char)(asciiValue)+" ");
                    asciiValue--;
                }
                //Prints a newline
                System.out.println();
            }
        }
    }
}


Output:

Character : Z
Rows : 5

Z
Z X
Z X W
Z X W V
Z X W V U

C CODE:

#include <stdio.h>

int main()
{
    //Taking character to be 
    //printed as input from the user
    printf("Character : ");
    char c;
    scanf("%c", &c);

    //Taking number of rows as input from the user
    printf("Rows : ");
    int row_count;
    scanf("%d", &row_count);

    int row, col;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 0; row < row_count; row++)
        {
            //Reseting the character 
            //after each iteration;
            asciiValue = c;
            //Inner loop to iterate columns
            for (col = 0; col < row + 1; col++)
            {
                printf("%c ", (char)(asciiValue));
                asciiValue--;
            }
            //Prints a newline
            printf("\n");
        }
    }
    return 0;
}
Output:

Character : Z
Rows : 5

Z
Z X
Z X W
Z X W V
Z X W V U

C++ CODE:

#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    //Taking character to be printed as input from the user
    cout << "Character : ";
    char c;
    cin >> c;

    //Taking number of rows as input from the user
    cout << "Rows : ";
    int row_count;
    cin >> row_count;

    int row, col;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 0; row < row_count; row++)
        {
            //Reseting the character after each iteration
            asciiValue = c;
            //Inner loop to iterate columns
            for (col = 0; col < row + 1; col++)
            {
                cout << (char)asciiValue << " ";
                asciiValue--;
            }
            //Prints a newline
            cout << endl;
        }
    }
    return 0;
}


Output:

Character : Z
Rows : 5

Z
Z X
Z X W
Z X W V
Z X W V U

Related Java Star Pattern Programs:

Java Program to Print Mirrored Right-Angled Triangle with Repeated Character (Decreasing Order) Pattern

Program to Print Mirrored Right-Angled Triangle with Repeated Character (Decreasing Order) Pattern

In the previous article, we have discussed Java Program to Print Mirrored Right-Angled Triangle with Repeated Character (Increasing Order) Pattern

In this program we are going to see how to print a mirrored right-angled triangle character pattern in decreasing order.

Example-1

When character=p
and row value=4

       p
     oo
   nnn
mmm
Example-2:

When character=G 

and row value=5

          E
       DD
      CCC
    BBBB
 AAAAA

Now, let’s see the actual program to print it.

The best and excellent way to learn a java programming language is by practicing Simple Java Program Examples as it includes basic to advanced levels of concepts.

Approach:

  • Enter the character and store it in a variable c.
  • Then enter total row and store it in an integer variable row_count.
  • Take one outer for loop to iterate the rows.
  • Take one inner loop to iterate the columns and print the character.
  • After each iteration print a newline.

Java Code to Print Mirrored Right-Angled Triangle with Repeated Character (Decreasing Order) Pattern

import java.util.Scanner;
class Main
{
public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    //Taking character to be printed as input from the user
    System.out.print("Character : ");
    char c = scan.next().charAt(0);

    //Taking number of rows as input from the user
    System.out.print("Rows : ");
    int row_count = scan.nextInt();

    int row, col, hold=row_count-1;
    //Converting the character to its ascii value
    int asciiValue = (int) c;

    //Checks whether the character is a letter or not
    if(asciiValue>=65&&asciiValue<=122)
    {
        
        //Outer loop to iterate rows
        for (row = 1; row <= row_count; row++)
        {
            //Inner loop to print space
            for (col = 1; col <=hold; col++)
            {
                System.out.print(" ");
            }
            hold--;
            //Inner loop to print character
            for(col = 1; col<=row; col++)
            {
                System.out.print(c);
                
            }
            c--;
            //Prints a newline
            System.out.println();
        }
    }
}
}

Output

Character : E
Rows : 5

         E
      DD
     CCC
   BBBB
AAAAA

C Code to Print Mirrored Right-Angled Triangle with Repeated Character (Decreasing Order) Pattern

#include <stdio.h>

int main()
{
    //Taking character to be printed as input from the user
    printf("Character : ");
    char c;
    scanf("%c", &c);

    //Taking number of rows as input from the user
    printf("Rows : ");
    int row_count;
    scanf("%d", &row_count);

    int row, col, hold = row_count - 1;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 1; row <= row_count; row++)
        {
            //Inner loop to print space
            for (col = 1; col <= hold; col++)
            {
                printf(" ");
            }
            hold--;
            //Inner loop to print character
            for (col = 1; col <= row; col++)
            {
                printf("%c", c);
            }
            c--;
            //Prints a newline
            printf("\n");
        }
    }
    return 0;
}
Output

Character : E
Rows : 5

         E
      DD
     CCC
    BBBB
 AAAAA

C++ Code to Print Mirrored Right-Angled Triangle with Repeated Character (Decreasing Order) Pattern

#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    //Taking character to be printed as input from the user
    cout << "Character : ";
    char c;
    cin >> c;

    //Taking number of rows as input from the user
    cout << "Rows : ";
    int row_count;
    cin >> row_count;

    int row, col, hold = row_count - 1;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 1; row <= row_count; row++)
        {
            //Inner loop to print space
            for (col = 1; col <= hold; col++)
            {
                cout << " ";
            }
            hold--;
            //Inner loop to print character
            for (col = 1; col <= row; col++)
            {
                cout << c;
            }
            c--;
            //Prints a newline
            cout << endl;
        }
    }
    return 0;
}

Output:

Character : E
Rows : 5

          E
       DD
     CCC
   BBBB
AAAAA

Are you seeking professional help for coding in the Java programming language? The tutorial of Java Programming Examples for beginners and experts will strongly improve your coding skills then you can program for any logic in Java.

Related Java Character Pattern Programs:

Java Program to Print Right Angled Triangle with Column Wise Increasing Character Pattern

Program to Print Right Angled Triangle with Column Wise Increasing Character Pattern

In this program we are going to see how to print the right angled triangle with column wise increasing character pattern.

Example-1

When character=h 
and row value=3

h
i k
j l m
Example-2:

When character=A 
and row value=5

A
B F
C G J
D H K M
E  I  L  N O

Now, let’s see the actual program to print it.

Access the Simple Java program for Interview examples with output from our page and impress your interviewer panel with your coding skills.

Approach:

  • Enter the character and store it in a variable c.
  • Then enter total row and store it in an integer variable row_count.
  • Take one outer for loop to iterate the rows.
  • Take one inner loop to iterate the columns and print the character.
  • After each iteration print a new line.

JAVA CODE:

import java.util.Scanner;
class Main
    {
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        //Taking character 
        //to be printed as input from the user
        System.out.print("Character : ");
        char c = scan.next().charAt(0);
    
        //Taking number of rows 
        //as input from the user
        System.out.print("Rows : ");
        int row_count = scan.nextInt();
    
        int row, col, charDif;
        //Converting the character to its ascii value
        int asciiValue = (int) c;
    
        //Checks whether the character is a letter or not
        if(asciiValue>=65&&asciiValue<=122)
        {
            
            //Outer loop to iterate rows
            for(row = 0; row<row_count; row++)
            {
            //Reseting the character difference and 
            //incrementing the character after each iteration
                charDif = row_count-1;
                asciiValue = c++;
                //Inner loop to iterate columns
                for(col = 0; col<row+1; col++)
                {
                    System.out.print((char)(asciiValue)+" ");
                    asciiValue+=charDif;
                    charDif--;
                }
                //Prints a newline
                System.out.println();
            }
        }
    }
}

Output:

Character : A
Rows : 5

A
B F
C G J
D H K M
E  I  L  N O

C CODE:

#include <stdio.h>

int main()
{
    //Taking character to be printed as input from the user
    printf("Character : ");
    char c;
    scanf("%c", &c);

    //Taking number of rows as input from the user
    printf("Rows : ");
    int row_count;
    scanf("%d", &row_count);

    int row, col, charDif;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 0; row < row_count; row++)
        {
            //Reseting the character difference and 
            //incrementing the character after each iteration
            charDif = row_count - 1;
            asciiValue = c++;
            //Inner loop to iterate columns
            for (col = 0; col < row + 1; col++)
            {
                printf("%c ", (char)(asciiValue));
                asciiValue += charDif;
                charDif--;
            }
            //Prints a newline
            printf("\n");
        }
    }
    return 0;
}
Output:

Character : A
Rows : 5

A
B F
C G J
D H K M
E  I  L  N O

C++ CODE:

#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    //Taking character to be printed as input from the user
    cout << "Character : ";
    char c;
    cin >> c;

    //Taking number of rows as input from the user
    cout << "Rows : ";
    int row_count;
    cin >> row_count;

    int row, col, charDif;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 0; row < row_count; row++)
        {
            //Reseting the character difference and 
            //incrementing the character after each iteration
            charDif = row_count - 1;
            asciiValue = c++;
            //Inner loop to iterate columns
            for (col = 0; col < row + 1; col++)
            {
                cout << (char)asciiValue << " ";
                asciiValue += charDif;
                charDif--;
            }
            //Prints a newline
            cout << endl;
        }
    }
    return 0;
}

Output:

Character : A
Rows : 5

A
B F
C G J
D H K M
E  I  L N O

Related Java Star Pattern Programs:

Java Program to Print Mirrored Right-Angled Triangle with Repeated Character (Increasing Order) Pattern

Program to Print Mirrored Right-Angled Triangle with Repeated Character (Increasing Order) Pattern

In the previous article, we have discussed Java Program to Print Equilateral Triangle Character Pattern

In this program we are going to see how to print a mirrored right-angled triangle character pattern.

Example-1:
When character=h
and row value =3
   h
  i i 
j j j
Example-2:

When character=A 
and row value=4

        A
      BB
    CCC
 DDDD

Now, let’s see the actual program to print it.

Provided list of Simple Java Programs is specially designed for freshers and beginners to get familiarize with the concepts of Java programming language and become pro in coding.

Approach:

  • Enter the character and store it in a variable c.
  • Then enter total row and store it in an integer variable row_count.
  • Take one outer for loop to iterate the rows.
  • Take one inner loop to iterate the columns and print the character.
  • After each iteration print a new line.

Java Code to Print Mirrored Right-Angled Triangle with Repeated Character (Increasing Order) Pattern

import java.util.Scanner;
class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        //Taking character to be printed as input from the user
        System.out.print("Character : ");
        char c = scan.next().charAt(0);
    
        //Taking number of rows as input from the user
        System.out.print("Rows : ");
        int row_count = scan.nextInt();
    
        int row, col, hold=row_count-1;
        //Converting the character to its ascii value
        int asciiValue = (int) c;
    
        //Checks whether the character is a letter or not
        if(asciiValue>=65&&asciiValue<=122)
        {
            
            //Outer loop to iterate rows
            for (row = 1; row <= row_count; row++)
            {
                //Inner loop to print space
                for (col = 1; col <=hold; col++)
                {
                    System.out.print(" ");
                }
                hold--;
                //Inner loop to print character
                for(col = 1; col<=row; col++)
                {
                    System.out.print(c);
                    
                }
                c++;
                //Prints a newline
                System.out.println();
            }
        }
    }
}
Output:

Character : A
Rows : 4

       A
      BB
    CCC
 DDDD

C Code to Print Mirrored Right-Angled Triangle with Repeated Character (Increasing Order) Pattern

#include <stdio.h>

int main()
{
    //Taking character to be printed as input from the user
    printf("Character : ");
    char c;
    scanf("%c", &c);

    //Taking number of rows as input from the user
    printf("Rows : ");
    int row_count;
    scanf("%d", &row_count);

    int row, col, hold = row_count - 1;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 1; row <= row_count; row++)
        {
            //Inner loop to print space
            for (col = 1; col <= hold; col++)
            {
                printf(" ");
            }
            hold--;
            //Inner loop to print character
            for (col = 1; col <= row; col++)
            {
                printf("%c", c);
            }
            c++;
            //Prints a newline
            printf("\n");
        }
    }
    return 0;
}
Output

Character : A
Rows : 4

        A
       BB
     CCC
  DDDD

C++ Code to Print Mirrored Right-Angled Triangle with Repeated Character (Increasing Order) Pattern

#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    //Taking character to be printed as input from the user
    cout << "Character : ";
    char c;
    cin >> c;

    //Taking number of rows as input from the user
    cout << "Rows : ";
    int row_count;
    cin >> row_count;

    int row, col, hold = row_count - 1;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 1; row <= row_count; row++)
        {
            //Inner loop to print space
            for (col = 1; col <= hold; col++)
            {
                cout << " ";
            }
            hold--;
            //Inner loop to print character
            for (col = 1; col <= row; col++)
            {
                cout << c;
            }
            c++;
            //Prints a newline
            cout << endl;
        }
    }
    return 0;
}

Output:

Character : A
Rows : 4

        A
       BB
     CCC
  DDDD

Are you seeking professional help for coding in the Java programming language? The tutorial of Java Programming Examples for beginners and experts will strongly improve your coding skills then you can program for any logic in Java.

Related Java Character Pattern Programs:

Java Program to Print Alphabet T Character Pattern

Program to Print Alphabet T Character Pattern

In the previous article, we have discussed Java Program to Print Digit 8 Character Pattern

In this article we are going to see how to print the alphabet ‘T’ character pattern.

Example:

When Size : 5

 AAAAAA
      B  
      C  
      D  
      E

Now, let’s see the actual program to print it.

Practice Java programming from home without using any fancy software just by tapping on this Simple Java Programs for Beginners tutorial.

Approach:

  • Enter the size and store it in an integer variable size.
  • Take first for loop to print all rows.
  • Take second/inner for loop to print column values.
  • Then go on printing the character symbols according to the iteration.

Java Code to Print Alphabet T Character Pattern

import java.util.Scanner;
class Main
{
    public static void main(String[] args)  
    {  
        //starting ascii value taken 65
        int ascii=65;
        int r, c;
        Scanner scan = new Scanner(System.in);
        System.out.print("Size : ");
        //Taking size as input from user
        int size=scan.nextInt();
        
        //Outer loop
        for(r = 0; r<size; r++)
        {   
            //Inner loop
            for(c = 0; c<size; c++)
            {
                //Condition to print star
                if(r==0||c==size/2)
                    System.out.print((char)(r+ascii));
                else
                    System.out.print(" ");
            }        //Prints a new line
            System.out.println();
        }
    }
}
Size : 5
AAAAAA
   B  
   C  
   D  
   E

C Code to Print Alphabet T Character Pattern

#include <stdio.h>
int main(int argc, char const *argv[])
{
    int ascii=65;
    int size, r, c;
    
    printf("Size : ");
    //Taking size as input from user
    scanf("%d", &size);
    for (r = 0; r < size; r++)
    { //Outer loop
        for (c = 0; c < size; c++)
        { //Inner loop
            if (r == 0 || c == size / 2)
                //Condition to print star
                printf("%c",(r+ascii));
            else
                printf(" ");
        }
        //Prints a new line
        printf("\n");
    }
    return 0;
}
Output:

Size : 5

AAAAAA
     B  
     C  
     D  
     E

C++ Code to Print Alphabet T Character Pattern

#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    //starting ascii value taken 65
    int ascii=65;
    cout << "Size : ";
    //Taking size as input from user
    int size, r, c, k;
    cin >> size;
    for (r = 0; r < size; r++)
    { //Outer loop
        for (c = 0; c < size; c++)
        { //Inner loop
            if (r == 0 || c == size / 2)
                //Condition to print star
                cout << (char)(r+ascii);
            else
                cout << " ";
        }
        //Prints a new line
        cout << endl;
    }
    return 0;
}
Output:

Size : 5

AAAAAA
     B  
     C  
     D  
     E

Are you seeking professional help for coding in the Java programming language? The tutorial of Java Programming Examples for beginners and experts will strongly improve your coding skills then you can program for any logic in Java.

Related Java Character Pattern Programs:

Java Program to Print Inverted Right-Angled Triangle with Decreasing Character Pattern

Program to Print Inverted Right-Angled Triangle with Decreasing Character Pattern

In the previous article, we have discussed Java Program to Print Inverted Right-Angled Triangle with Row wise Increasing Character Pattern

In this program we are going to see how to print an inverted right-angled triangle with decreasing character pattern.

Example-1

When character=h 
and row value=3

hgf
gf
f
Example-2:

When character=E 
and row value=5

EDCBA
DCBA
CBA
BA
A

Now, let’s see the actual program to print it.

Are you wondering how to seek help from subject matter experts and learn the Java language? Go with these Basic Java Programming Examples and try to code all of them on your own then check with the exact code provided by expert programmers.

Approach:

  • Enter the character and store it in a variable c.
  • Then enter total row and store it in an integer variable row_count.
  • Take one outer for loop to iterate the rows.
  • Take one inner loop to iterate the columns and print the character.
  • After each iteration print a new line.

Java Code to Print Inverted Right-Angled Triangle with Decreasing Character Pattern

import java.util.Scanner;
class Main
{
public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    //Taking character to be printed as input from the user
    System.out.print("Character : ");
    char c = scan.next().charAt(0);

    //Taking number of rows as input from the user
    System.out.print("Rows : ");
    int row_count = scan.nextInt();

    int row, col;
    //Converting the character to its ascii value
    int asciiValue = (int) c;

    //Checks whether the character is a letter or not
    if(asciiValue>=65&&asciiValue<=122)
    {
        
        //Outer loop to iterate rows
        for (row = 0; row < row_count; row++)
        {
            c = (char)asciiValue;
            //Inner loop to print star
            for(col = 0; col<row_count-row; col++)
            {
                System.out.print(c--);
            }
            asciiValue--;
            //Prints a newline
            System.out.println();
        }
    }
}
}
Output:

Character : E
Rows : 5

EDCBA
DCBA
CBA
BA
A

C Code to Print Inverted Right-Angled Triangle with Decreasing Character Pattern

#include <stdio.h>

int main()
{
    //Taking character to be printed as input from the user
    printf("Character : ");
    char c;
    scanf("%c", &c);

    //Taking number of rows as input from the user
    printf("Rows : ");
    int row_count;
    scanf("%d", &row_count);

    int row, col;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 0; row < row_count; row++)
        {
            c = (char)asciiValue;
            //Inner loop to print star
            for (col = 0; col < row_count - row; col++)
            {
                printf("%c", c--);
            }
            asciiValue--;
            //Prints a newline
            printf("\n");
        }
    }
    return 0;
}

Output:

Character : E
Rows : 5

EDCBA
DCBA
CBA
BA
A

C++ Code to Print Inverted Right-Angled Triangle with Decreasing Character Pattern

#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    //Taking character to be printed as input from the user
    cout << "Character : ";
    char c;
    cin >> c;

    //Taking number of rows as input from the user
    cout << "Rows : ";
    int row_count;
    cin >> row_count;

    int row, col;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 0; row < row_count; row++)
        {
            c = (char)asciiValue;
            //Inner loop to print star
            for (col = 0; col < row_count - row; col++)
            {
                cout << c--;
            }
            asciiValue--;
            //Prints a newline
            cout << endl;
        }
    }
    return 0;
}

Output:

Character : E
Rows : 5

EDCBA
DCBA
CBA
BA
A

Are you seeking professional help for coding in the Java programming language? The tutorial of Java Programming Examples for beginners and experts will strongly improve your coding skills then you can program for any logic in Java.

Related Java Character Pattern Programs:

Java Program to Print Right Angled Triangle with Repeating Character (Decreasing Order) Pattern

Program to Print Right Angled Triangle with Repeating Character Pattern (Decreasing Order)

In this program we are going to see how to print the right angled triangle with repeating character pattern in decreasing order.

Example-1

When character=h 
and row value=3

h
g g
f  f  f
Example-2:

When character=Z 
and row value=5

Z
Y Y
X X X
W W W W
V  V  V  V  V

Now, let’s see the actual program to print it.

Interested in programming and want to excel in it by choosing the short ways. Then, practicing with the available Java Program list is mandatory.

Approach:

  • Enter the character and store it in a variable c
  • Then enter total row and store it in an integer variable row_count.
  • Take one outer for loop to iterate the rows.
  • Take one inner loop to iterate the columns and print the character.
  • After each iteration print a new line.

JAVA CODE:

import java.util.Scanner;
class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        //Taking character to be printed 
        // as input from the user
        System.out.print("First Character : ");
        char c = scan.next().charAt(0);
    
        //Taking number of rows as input from the user
        System.out.print("Rows : ");
        int row_count = scan.nextInt();
    
        int row, col;
        //Converting the character to its ascii value
        int asciiValue = (int) c;
    
        //Checks whether the character is a letter or not
        if(asciiValue>=65&&asciiValue<=122)
        {
            //Outer loop to iterate rows
            for(row = 0; row<row_count; row++)
            {
                //Inner loop to iterate columns
                for(col = 0; col<row+1; col++)
                {
                    System.out.print(c+" ");
                }
                //Decrementing the character
                    c--;
                //Prints a newline
                System.out.println();
            }
        }
    }
}
Output:

Character : Z
Rows : 5

Z
Y  Y
X  X  X
W W W W
V  V  V  V  V

C CODE:

#include <stdio.h>

int main()
{
    //Taking character to be printed as input from the user
    printf("Character : ");
    char c;
    scanf("%c", &c);

    //Taking number of rows as input from the user
    printf("Rows : ");
    int row_count;
    scanf("%d", &row_count);

    int row, col;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 0; row < row_count; row++)
        {
            //Inner loop to iterate columns
            for (col = 0; col < row + 1; col++)
            {
                printf("%c ", c);
            }
            //Decrementing the character
            c--;
            //Prints a newline
            printf("\n");
        }
    }
    return 0;
}

Output:

Character : Z
Rows : 5

Z
Y  Y
X  X  X
W W W W
V  V  V  V  V

C++ CODE:

#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    //Taking character to be printed as input from the user
    cout << "Character : ";
    char c;
    cin >> c;

    //Taking number of rows as input from the user
    cout << "Rows : ";
    int row_count;
    cin >> row_count;

    int row, col;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 0; row < row_count; row++)
        {
            //Inner loop to iterate columns
            for (col = 0; col < row + 1; col++)
            {
                cout << c << " ";
            }
            //Decrementing the character
            c--;
            //Prints a newline
            cout << endl;
        }
    }
    return 0;
}

Output:

Character : Z
Rows : 5

Z
Y  Y
X  X  X
W W W W
V  V  V  V  V

Related Java Star Pattern Programs:

Java Program to Print Right Angled Triangle with Repeating Character (Increasing Order) Pattern

Program to Print Right Angled Triangle with Repeating Character Pattern (Increasing Order)

In this program we are going to see how to print the right angled triangle with repeating character pattern in increasing order.

Example-1

When character=h 
and row value=3

h
i i
j j j
Example-2:

When character=A 
and row value=5

A
B B
C C C
D D D D
E  E  E  E E

Now, let’s see the actual program to print it.

Practice Java programming from home without using any fancy software just by tapping on this Simple Java Programs for Beginners tutorial.

Approach:

  • Enter the character and store it in a variable c.
  • Then enter total row and store it in an integer variable row_count.
  • Take one outer for loop to iterate the rows.
  • Take one inner loop to iterate the columns and print the character.
  • After each iteration print a newline.

JAVA CODE:

import java.util.Scanner;
class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        //Taking character to be printed 
        //as input from the user
        System.out.print("First Character : ");
        char c = scan.next().charAt(0);
    
        //Taking number of rows as input from the user
        System.out.print("Rows : ");
        int row_count = scan.nextInt();
    
        int row, col;
        //Converting the character to its ascii value
        int asciiValue = (int) c;
    
        //Checks whether the character is a letter or not
        if(asciiValue>=65&&asciiValue<=122)
        {
            //Outer loop to iterate rows
            for(row = 0; row<row_count; row++)
            {
                //Inner loop to iterate columns
                for(col = 0; col<row+1; col++)
                {
                    System.out.print(c+" ");
                }
                //Incrementing the character
                    c++;
                //Prints a newline
                System.out.println();
            }
        }
    }
}

Output

Character : A
Rows : 5

A
B B
C C C
D D D D
E  E  E E E

C CODE:

#include <stdio.h>

int main()
{
    //Taking character to be printed as input from the user
    printf("Character : ");
    char c;
    scanf("%c", &c);

    //Taking number of rows as input from the user
    printf("Rows : ");
    int row_count;
    scanf("%d", &row_count);

    int row, col;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 0; row < row_count; row++)
        {
            //Inner loop to iterate columns
            for (col = 0; col < row + 1; col++)
            {
                printf("%c ", c);
            }
            //Incrementing the character
            c++;
            //Prints a newline
            printf("\n");
        }
    }
    return 0;
}

Output:

Character : A
Rows : 5

A
B B
C C C
D D D D
E  E  E E E

C++ CODE:

#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    //Taking character to be printed as input from the user
    cout << "Character : ";
    char c;
    cin >> c;

    //Taking number of rows as input from the user
    cout << "Rows : ";
    int row_count;
    cin >> row_count;

    int row, col;
    //Converting the character to its ascii value
    int asciiValue = (int)c;

    //Checks whether the character is a letter or not
    if (asciiValue >= 65 && asciiValue <= 122)
    {
        //Outer loop to iterate rows
        for (row = 0; row < row_count; row++)
        {
            //Inner loop to iterate columns
            for (col = 0; col < row + 1; col++)
            {
                cout << c << " ";
            }
            //Incrementing the character
            c++;
            //Prints a newline
            cout << endl;
        }
    }
    return 0;
}
Output:

Character : A
Rows : 5

A
B B
C C C
D D D D
E  E  E E E

Related Java Star Pattern Programs: