Print alphabets pattern - C++ Program

1. Write a C++ program to print the following pattern:

alphabets pattern 1

Answer:

#include<iostream>
using namespace std;
int main()
{
        int i, j, incr=1, cnt;
        cout<<"\n Enter Number of Rows : ";
        cin>>cnt;
        cout<<"\n";
        char ch = 'A';
        for(i=0; i<cnt; i++)
        {
                for(j=0; j<incr; j++)
                {
                        cout<<ch<<" ";
                        ch++;
                }
                cout<<"\n";
                incr = incr + 1;
        }
        return 0;
}


Output:

output alphabets pattern 1

2. Write a C++ program to print the following pattern:

alphabets pattern 2

Answer:

#include<iostream>
using namespace std;
int main()
{
        int i, j, cnt;
        cout<<"\n Enter Number of Rows : ";
        cin>>cnt;
        cout<<"\n";
        char ch='A';
        for(i=0; i<cnt; i++)
        {
                for(j=0; j<=i; j++)
                {
                        cout<<ch<<" ";
                }
                cout<<"\n";
                ch++;
        }
        return 0;
}


Output:

output alphabets pattern 2

3. Write a C++ program to print the following pattern:

alphabets pattern 3

Answer:

#include<iostream>
using namespace std;
int main()
{
        int i, j, k, decr=8, count=64, temp, rows;
        char ch='A';
        cout<<"\n Enter Number of Rows : ";
        cin>>rows;
        for(i=0; i<rows; i++)
        {
                for(k=0; k<decr; k++)
                {
                        cout<<" ";
                }
                for(j=0; j<i+1; j++)
                {
                        count++;
                }
                ch = count;
                temp = ch;
                for(j=0; j<i+1; j++)
                {
                        cout<<ch--<<" ";
                }
                cout<<"\n";
                ch = temp;
                decr=decr-2;
        }
        return 0;
}


Output:

output alphabets pattern 3