Skip to content
Programming101
Programming101

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programming101

Learn everything about programming

C++ program to display pattern of alphabets

YASH PAL, 31 July 202422 August 2024

In this post, we will write a C++ program to display patterns of alphabets. the first user will enter the number between 1-19 and then the program will print the pattern of that equivalent character on the output screen.

C++ program to display pattern of alphabets

C++ program to display patterns of alphabets.

#include<iostream>
#include<conio.h>
#include<windows.h>


BOOL gotoxy(const WORD x, const WORD y) {
    COORD xy;
    xy.X = x;
    xy.Y = y;
    return SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), xy);
}

int main()
{
    system("cls");
    int i,j,n;
    char ch;

    std::cout<<"Enter the number (1-19) you want the alphabets display = ";
    std::cin>>n;

    for(i=65;i<=65+n;i++)
    {
        for(j=1;j<=65+n-i;j++)
        {
                ch = i;
                gotoxy(i-64+i-64,j+5);
                std::cout<<ch<<std::endl;
        }
    }

    for(i=65+n;i>=65;i--)
        for(j=i;j<=65+n-1;j++)
        {
            ch = i;
            gotoxy(65+n-i+65+n-i+(n+n-2), 72-j+(n-2));
            std::cout<<ch<<std::endl;
        }

        getch();
        return 0;
}

Output

Enter the number(1-19) you want the alphabet display = 19

A B C D E F G H I J K L M N O P Q R S R Q P O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O P Q R   R Q P O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O P Q       Q P O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O P           P O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O               O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N                   N M L K J I H G F E D C B A
A B C D E F G H I J K L M                       M L K J I H G F E D C B A
A B C D E F G H I J K L                           L K J I H G F E D C B A
A B C D E F G H I J K                               K J I H G F E D C B A
A B C D E F G H I J                                   J I H G F E D C B A
A B C D E F G H I                                       I H G F E D C B A
A B C D E F G H                                           H G F E D C B A
A B C D E F G                                               G F E D C B A
A B C D E F                                                   F E D C B A
A B C D E                                                       E D C B A
A B C D                                                           D C B A
A B C                                                               C B A
A B                                                                   B A
A                                                                       A
coding problems cpp

Post navigation

Previous post
Next post
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
  • Hackerrank Day 14 scope 30 days of code solution
©2025 Programming101 | WordPress Theme by SuperbThemes