Open In App

Program to print the Alphabets of a Given Word using * pattern

Last Updated : 06 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Given a word str, the task is to print the alphabets of this word using * pattern.
Examples: 
 

Input: GFG
Output:
******
*
*
*
* ****
* * *
* * *
*** *

*******
**
**
******
**
**
**


******
*
*
*
* ****
* * *
* * *
*** *


Approach: A simple implementation is to form the pattern for each letter A-Z and call them as functions.
Below is the implementation of the above approach: 
 

C++
// C++ Program to print the Alphabets
// of a Given Word using * pattern
#include <iostream>
using namespace std;
char ch;

// Function to print the letter A
void a(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";
        for (int a = 0; a < 8; a++) {
            if (i == 0 && (a == 0 || a == 7))
                cout << " ";
            else if (a < 2 || a > 5) {
                cout << ch;
            }
            else if (i < 2 || (i > 3 && i < 5)) {
                cout << ch;
            }

            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter B
void b(void)
{
    cout << endl;
    for (int i = 0; i < 9; i++) {
        cout << ch << ch;

        for (int r = 0; r < 6; r++) {
            if (i == 0 && r < 5)
                cout << ch;
            else if (i == 1)
                cout << ch;
            else if (i < 4 && i > 0
                     && r > 3) {
                cout << ch;
            }

            else if (i == 4 && r < 5) {
                cout << ch;
            }
            else if (i > 4 && i < 7
                     && r > 3) {
                cout << ch;
            }
            else if (i == 7) {
                cout << ch;
            }
            else if (i == 8 && r < 5) {
                cout << ch;
            }

            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter C
void c(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {

        cout << " ";
        for (int o = 0; o < 8; o++) {
            if (i == 0 && (o <= 1))
                cout << " ";
            else if (i == 1
                     && (o == 0 || o == 8 - i
                         || (o > 1)))
                cout << " ";
            else if (i == 2
                     && (o == 1 || o == 8 - i
                         || (o > 1)))
                cout << " ";
            else if ((i == 3 || i == 4
                      || i == 5)
                     && (o > 0))
                cout << " ";
            else if (i == 6
                     && (o == 0 || o == 8 + 5 - i
                         || (o > 1)))
                cout << " ";
            else if (i == 7
                     && (o <= 1))
                cout << " ";
            else {
                cout << ch;
            }
        }
        cout << endl;
    }
}

// Function to print the letter D
void d(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        {
            cout << " "<< ch;
        }

        for (int o = 0; o < 8; o++) {
            if (i == 0 && (o >= 6 - i))
                cout << " ";
            else if (i == 1
                     && (o == 0 || o == 8 - i
                         || (o < 6)))
                cout << " ";
            else if (i == 2
                     && (o == 1 || o == 8 - i
                         || (o < 6)))
                cout << " ";
            else if ((i == 3 || i == 4
                      || i == 5)
                     && (o < 7))
                cout << " ";
            else if (i == 6
                     && (o == 0 || o == 8 + 5 - i
                         || (o < 6)))
                cout << " ";
            else if (i == 7
                     && (o >= 6 - i + 7))
                cout << " ";
            else {
                cout << ch;
            }
        }
        cout << endl;
    }
}

// Function to print the letter E
void e(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";
        for (int j = 0; j < 7; j++) {
            if (i == 0) {
                cout << ch;
            }
            else if (i > 0 && i < 3
                     && j < 2) {
                cout << ch;
            }
            else if (i == 3 && j < 6) {
                cout << ch;
            }
            else if (i > 3 && i < 6
                     && j < 2) {
                cout << ch;
            }
            else if (i == 6) {
                cout << ch;
            }

            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter F
void f(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";
        for (int j = 0; j < 7; j++) {
            if (i == 0) {
                cout << ch;
            }
            else if (i > 0 && i < 3
                     && j < 2) {
                cout << ch;
            }
            else if (i == 3 && j < 6) {
                cout << ch;
            }
            else if (i > 3 && i < 7
                     && j < 2) {
                cout << ch;
            }

            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter G
void g(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {

        cout << " ";
        for (int o = 0; o < 8; o++) {
            if (i == 4 && o > 3
                || (o == 4 || o == 7)
                       && i > 4) {
                cout << ch;
            }

            else if (i == 0 && (o <= 1))
                cout << " ";
            else if (i == 1
                     && (o == 0 || o == 8 - i
                         || (o > 1)))
                cout << " ";
            else if (i == 2
                     && (o == 1 || o == 8 - i
                         || (o > 1)))
                cout << " ";
            else if ((i == 3 || i == 4
                      || i == 5)
                     && (o > 0))
                cout << " ";
            else if (i == 6
                     && (o == 0 || (o > 1)))
                cout << " ";
            else if (i == 7
                     && (o <= 1 || o == 5
                         || o == 6))
                cout << " ";
            else {
                cout << ch;
            }
        }
        cout << endl;
    }
}

// Function to print the letter H
void h(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";
        for (int h = 0; h < 8; h++) {
            if (h < 2 || h > 5) {
                cout << ch;
            }
            else if (i > 2 && i < 5) {
                cout << ch;
            }

            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter I
void i(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {

        cout << " ";

        for (int t = 0; t < 8; t++) {

            if ((i < 1 || i > 6)
                && t < 8) {
                cout << ch;
            }

            else if (i > 0 && t < 3)
                cout << " ";
            else if (i > 0 && t > 2
                     && t < 5) {
                cout << ch;
            }
            else if (i > 0 && t > 4)
                cout << " ";
            else {
            }
        }
        cout << endl;
    }
}

// Function to print the letter J
void j(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";

        for (int h = 0; h < 8; h++) {
            if (i < 1) {
                cout << ch;
            }
            else if (i == 5 && h < 1) {
                cout << ch;
            }
            else if (i < 7 && h > 5) {
                cout << ch;
            }
            else if (i == 7
                     && (h == 0 || h == 7))
                cout << " ";
            else if (i > 5) {
                cout << ch;
            }
            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter K
void k(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";

        for (int k1 = 0; k1 < 7; k1++) {
            if (k1 < 2) {
                cout << ch;
            }
            else if ((k1 >= 5 - i)
                     && (k1 <= 6 - i)) {
                cout << ch;
            }

            else if (i >= 4) {
                if (k1 == i - 2 || k1 == i - 1) {
                    cout << ch;
                }
                else
                    cout << " ";
            }
            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter L
void l(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";

        {
            cout << ch << ch;
        }
        if (i == 6) {
            {
                cout << ch << ch;
            }
            {
                cout << ch << ch;
            }
            cout << ch << ch;
        }
        if (i == 7) {
            {
                cout << ch << ch;
            }
            {
                cout << ch << ch;
            }
            cout << ch << ch;
        }
        cout << endl;
    }
}

// Function to print the letter M
void m(void)
{
    cout << endl;

    for (int i = 0; i < 8; i++) {
        cout << " ";
        for (int j = 0; j < 8; j++) {
            if (j == 0 || j == 7) {
                cout << ch;
            }
            else if (i < 4
                     && (j == 7 - i || j == i)) {
                cout << ch;
            }
            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter N
void n(void)
{
    cout << endl;

    for (int i = 0; i < 8; i++) {
        cout << " ";
        for (int n = 0; n < 8; n++) {
            if (n < 2 || n > 5) {
                cout << ch;
            }
            else if (i == n - 1
                     || i == n + 1 || i == n) {
                cout << ch;
            }
            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter O
void o(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";
        for (int o = 0; o < 8; o++) {
            if (i == 0 && (o <= 1 || o >= 6 - i))
                cout << " ";
            else if (i == 1
                     && (o == 0 || o == 8 - i
                         || (o < 6 && o > 1)))
                cout << " ";
            else if (i == 2
                     && (o == 1 || o == 8 - i
                         || (o < 6 && o > 1)))
                cout << " ";
            else if ((i == 3 || i == 4 || i == 5)
                     && (o > 0 && o < 7))
                cout << " ";
            else if (i == 6
                     && (o == 0 || o == 8 + 5 - i
                         || (o < 6 && o > 1)))
                cout << " ";
            else if (i == 7
                     && (o <= 1 || o >= 6 - i + 7))
                cout << " ";
            else {
                cout << ch;
            }
        }
        cout << endl;
    }
}

// Function to print the letter P
void p(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";
        {
            cout << ch << ch;
        }

        for (int r = 0; r < 6; r++) {
            if (i == 0 && r < 5)
                cout << ch;
            else if (i == 1)
                cout << ch;
            else if (i < 4 && i > 0 && r > 3) {
                cout << ch;
            }

            else if (i == 4 && r < 5) {
                cout << ch;
            }
            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter Q
void q(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";
        for (int o = 0; o < 8; o++) {
            if (o == i)
                cout << ch;

            else if (i == 0
                     && (o <= 1 || o >= 6 - i))
                cout << " ";
            else if (i == 1
                     && (o == 0 || o == 8 - i
                         || (o < 6 && o > 1)))
                cout << " ";
            else if (i == 2
                     && (o == 1 || o == 8 - i
                         || (o < 6 && o > 1)))
                cout << " ";
            else if ((i == 3 || i == 4 || i == 5)
                     && (o > 0 && o < 7))
                cout << " ";
            else if (i == 6
                     && (o == 0 || o == 8 + 5 - i
                         || (o < 6 && o > 1)))
                cout << " ";
            else if (i == 7
                     && (o <= 1 || o >= 6 - i + 7))
                cout << " ";
            else {
                cout << ch;
            }
        }
        cout << endl;
    }
}

// Function to print the letter R
void r(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";
        {
            cout << ch << ch;
        }

        for (int r = 0; r < 6; r++) {
            if (i == 0 && r < 5)
                cout << ch;
            else if (i == 1)
                cout << ch;
            else if (i < 4 && i > 0
                     && r > 3) {
                cout << ch;
            }

            else if (i >= 4) {
                if (i == 4
                    && (r == 3 || r == 4)) {
                    cout << ch;
                }

                else if (r == i - 2
                         || r == i - 3) {
                    cout << ch;
                }
                else
                    cout << " ";
            }
            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter S
void s(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";
        for (int j = 0; j < 7; j++) {
            if (i == 0 && j > 0) {
                cout << ch;
            }
            else if (i > 0 && i < 3
                     && j < 2) {
                cout << ch;
            }
            else if (i == 3 && j > 0
                     && j < 6) {
                cout << ch;
            }
            else if (i > 3 && i < 6
                     && j > 4) {
                cout << ch;
            }
            else if (i == 6 && j < 6) {
                cout << ch;
            }

            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter T
void t(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {

        cout << " ";
        for (int t = 0; t < 8; t++) {

            if (i < 2 && t < 8) {
                cout << ch;
            }

            if (i > 1 && t < 3)
                cout << " ";
            if (i > 1 && t > 2
                && t < 5) {
                cout << ch;
            }
            if (i > 1 && t > 4)
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter U
void u(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";

        for (int h = 0; h < 8; h++) {
            if (i < 7 && (h < 2 || h > 5)) {
                cout << ch;
            }
            else if (i == 7
                     && (h == 0 || h == 7))
                cout << " ";
            else if (i > 5) {
                cout << ch;
            }
            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter V
void v(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";
        for (int v = 0; v < 8; v++)
            if ((v == 0 || v == 7)
                && i < 4) {
                cout << ch;
            }
            else if ((v == i - 4 || v == 11 - i)
                     && i >= 4) {
                cout << ch;
            }
            else
                cout << " ";
        cout << endl;
    }
}

// Function to print the letter W
void w(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";
        for (int j = 0; j < 8; j++) {
            if (j == 0 || j == 7) {
                cout << ch;
            }
            else if (i > 3
                     && (j == 7 - i || j == i)) {
                cout << ch;
            }
            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter X
void x(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";
        for (int m = 0; m < 8; m++) {
            if (i == m || m == 7 - i) {
                cout << ch;
            }
            else
                cout << " ";
        }

        cout << endl;
    }
}

// Function to print the letter Y
void y(void)
{
    cout << endl;
    for (int i = 0; i < 8; i++) {
        cout << " ";

        for (int y = 0; y < 8; y++) {
            if (i < 4) {
                if (y == i || y == i + 1
                    || y == 6 - i || y == 7 - i) {
                    cout << ch;
                }
                else
                    cout << " ";
            }
            else if (y == 3 || y == 4) {
                cout << ch;
            }
            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the letter Z
void z(void)
{
    cout << endl;

    for (int i = 0; i < 8; i++) {
        cout << " ";
        for (int j = 0; j < 8; j++) {
            if (i == 0 || i == 7) {
                cout << ch;
            }
            else if (j == 7 - i) {
                cout << ch;
            }
            else
                cout << " ";
        }
        cout << endl;
    }
}

// Function to print the required pattern
// by taking out each characters in it
void printPattern(char* str)
{

    int in = 0;

    while (str[in]) {

        char ch = str[in];
        if (ch < 95)
            ch = ch + 32;
        switch (ch) {
        case 'a':
            a();
            break;
        case 'b':
            b();
            break;
        case 'c':
            c();
            break;
        case 'd':
            d();
            break;
        case 'e':
            e();
            break;
        case 'f':
            f();
            break;
        case 'g':
            g();
            break;
        case 'h':
            h();
            break;
        case 'i':
            i();
            break;
        case 'j':
            j();
            break;
        case 'k':
            k();
            break;
        case 'l':
            l();
            break;
        case 'm':
            m();
            break;
        case 'n':
            n();
            break;
        case 'o':
            o();
            break;
        case 'p':
            p();
            break;
        case 'q':
            q();
            break;
        case 'r':
            r();
            break;
        case 's':
            s();
            break;
        case 't':
            t();
            break;
        case 'u':
            u();
            break;
        case 'v':
            v();
            break;
        case 'w':
            w();
            break;
        case 'x':
            x();
            break;
        case 'y':
            y();
            break;
        case 'z':
            z();
            break;
        default:
            break;
        }
        in++;
    }
}

// Driver code
int main()
{
    ch = '*';
    char *str = "GFG";
    printPattern(str);

    return 0;
}

// This code is contributed by shubhamsingh
C
// C Program to print the Alphabets
// of a Given Word using * pattern

#include <stdio.h>
#include <string.h>

char ch;

// Function to print the letter A
void a(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");
        for (int a = 0; a < 8; a++) {
            if (i == 0 && (a == 0 || a == 7))
                printf(" ");
            else if (a < 2 || a > 5) {
                printf("%c", ch);
            }
            else if (i < 2 || (i > 3 && i < 5)) {
                printf("%c", ch);
            }

            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter B
void b(void)
{
    printf("\n");
    for (int i = 0; i < 9; i++) {
        printf(" %c%c", ch, ch);

        for (int r = 0; r < 6; r++) {
            if (i == 0 && r < 5)
                printf("%c", ch);
            else if (i == 1)
                printf("%c", ch);
            else if (i < 4 && i > 0
                     && r > 3) {
                printf("%c", ch);
            }

            else if (i == 4 && r < 5) {
                printf("%c", ch);
            }
            else if (i > 4 && i < 7
                     && r > 3) {
                printf("%c", ch);
            }
            else if (i == 7) {
                printf("%c", ch);
            }
            else if (i == 8 && r < 5) {
                printf("%c", ch);
            }

            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter C
void c(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {

        printf(" ");
        for (int o = 0; o < 8; o++) {
            if (i == 0 && (o <= 1))
                printf(" ");
            else if (i == 1
                     && (o == 0 || o == 8 - i
                         || (o > 1)))
                printf(" ");
            else if (i == 2
                     && (o == 1 || o == 8 - i
                         || (o > 1)))
                printf(" ");
            else if ((i == 3 || i == 4
                      || i == 5)
                     && (o > 0))
                printf(" ");
            else if (i == 6
                     && (o == 0 || o == 8 + 5 - i
                         || (o > 1)))
                printf(" ");
            else if (i == 7
                     && (o <= 1))
                printf(" ");
            else {
                printf("%c", ch);
            }
        }
        printf("\n");
    }
}

// Function to print the letter D
void d(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        {
            printf(" %c", ch);
        }

        for (int o = 0; o < 8; o++) {
            if (i == 0 && (o >= 6 - i))
                printf(" ");
            else if (i == 1
                     && (o == 0 || o == 8 - i
                         || (o < 6)))
                printf(" ");
            else if (i == 2
                     && (o == 1 || o == 8 - i
                         || (o < 6)))
                printf(" ");
            else if ((i == 3 || i == 4
                      || i == 5)
                     && (o < 7))
                printf(" ");
            else if (i == 6
                     && (o == 0 || o == 8 + 5 - i
                         || (o < 6)))
                printf(" ");
            else if (i == 7
                     && (o >= 6 - i + 7))
                printf(" ");
            else {
                printf("%c", ch);
            }
        }
        printf("\n");
    }
}

// Function to print the letter E
void e(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");
        for (int j = 0; j < 7; j++) {
            if (i == 0) {
                printf("%c", ch);
            }
            else if (i > 0 && i < 3
                     && j < 2) {
                printf("%c", ch);
            }
            else if (i == 3 && j < 6) {
                printf("%c", ch);
            }
            else if (i > 3 && i < 6
                     && j < 2) {
                printf("%c", ch);
            }
            else if (i == 6) {
                printf("%c", ch);
            }

            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter F
void f(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");
        for (int j = 0; j < 7; j++) {
            if (i == 0) {
                printf("%c", ch);
            }
            else if (i > 0 && i < 3
                     && j < 2) {
                printf("%c", ch);
            }
            else if (i == 3 && j < 6) {
                printf("%c", ch);
            }
            else if (i > 3 && i < 7
                     && j < 2) {
                printf("%c", ch);
            }

            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter G
void g(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {

        printf(" ");
        for (int o = 0; o < 8; o++) {
            if (i == 4 && o > 3
                || (o == 4 || o == 7)
                       && i > 4) {
                printf("%c", ch);
            }

            else if (i == 0 && (o <= 1))
                printf(" ");
            else if (i == 1
                     && (o == 0 || o == 8 - i
                         || (o > 1)))
                printf(" ");
            else if (i == 2
                     && (o == 1 || o == 8 - i
                         || (o > 1)))
                printf(" ");
            else if ((i == 3 || i == 4
                      || i == 5)
                     && (o > 0))
                printf(" ");
            else if (i == 6
                     && (o == 0 || (o > 1)))
                printf(" ");
            else if (i == 7
                     && (o <= 1 || o == 5
                         || o == 6))
                printf(" ");
            else {
                printf("%c", ch);
            }
        }
        printf("\n");
    }
}

// Function to print the letter H
void h(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");
        for (int h = 0; h < 8; h++) {
            if (h < 2 || h > 5) {
                printf("%c", ch);
            }
            else if (i > 2 && i < 5) {
                printf("%c", ch);
            }

            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter I
void i(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {

        printf(" ");

        for (int t = 0; t < 8; t++) {

            if ((i < 1 || i > 6)
                && t < 8) {
                printf("%c", ch);
            }

            else if (i > 0 && t < 3)
                printf(" ");
            else if (i > 0 && t > 2
                     && t < 5) {
                printf("%c", ch);
            }
            else if (i > 0 && t > 4)
                printf(" ");
            else {
            }
        }
        printf("\n");
    }
}

// Function to print the letter J
void j(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");

        for (int h = 0; h < 8; h++) {
            if (i < 1) {
                printf("%c", ch);
            }
            else if (i == 5 && h < 1) {
                printf("%c", ch);
            }
            else if (i < 7 && h > 5) {
                printf("%c", ch);
            }
            else if (i == 7
                     && (h == 0 || h == 7))
                printf(" ");
            else if (i > 5) {
                printf("%c", ch);
            }
            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter K
void k(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");

        for (int k1 = 0; k1 < 7; k1++) {
            if (k1 < 2) {
                printf("%c", ch);
            }
            else if ((k1 >= 5 - i)
                     && (k1 <= 6 - i)) {
                printf("%c", ch);
            }

            else if (i >= 4) {
                if (k1 == i - 2 || k1 == i - 1) {
                    printf("%c", ch);
                }
                else
                    printf(" ");
            }
            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter L
void l(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");

        {
            printf("%c%c", ch, ch);
        }
        if (i == 6) {
            {
                printf("%c%c", ch, ch);
            }
            {
                printf("%c%c", ch, ch);
            }
            printf("%c%c", ch, ch);
        }
        if (i == 7) {
            {
                printf("%c%c", ch, ch);
            }
            {
                printf("%c%c", ch, ch);
            }
            printf("%c%c", ch, ch);
        }
        printf("\n");
    }
}

// Function to print the letter M
void m(void)
{
    printf("\n");

    for (int i = 0; i < 8; i++) {
        printf(" ");
        for (int j = 0; j < 8; j++) {
            if (j == 0 || j == 7) {
                printf("%c", ch);
            }
            else if (i < 4
                     && (j == 7 - i || j == i)) {
                printf("%c", ch);
            }
            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter N
void n(void)
{
    printf("\n");

    for (int i = 0; i < 8; i++) {
        printf(" ");
        for (int n = 0; n < 8; n++) {
            if (n < 2 || n > 5) {
                printf("%c", ch);
            }
            else if (i == n - 1
                     || i == n + 1 || i == n) {
                printf("%c", ch);
            }
            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter O
void o(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");
        for (int o = 0; o < 8; o++) {
            if (i == 0 && (o <= 1 || o >= 6 - i))
                printf(" ");
            else if (i == 1
                     && (o == 0 || o == 8 - i
                         || (o < 6 && o > 1)))
                printf(" ");
            else if (i == 2
                     && (o == 1 || o == 8 - i
                         || (o < 6 && o > 1)))
                printf(" ");
            else if ((i == 3 || i == 4 || i == 5)
                     && (o > 0 && o < 7))
                printf(" ");
            else if (i == 6
                     && (o == 0 || o == 8 + 5 - i
                         || (o < 6 && o > 1)))
                printf(" ");
            else if (i == 7
                     && (o <= 1 || o >= 6 - i + 7))
                printf(" ");
            else {
                printf("%c", ch);
            }
        }
        printf("\n");
    }
}

// Function to print the letter P
void p(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");
        {
            printf("%c%c", ch, ch);
        }

        for (int r = 0; r < 6; r++) {
            if (i == 0 && r < 5)
                printf("%c", ch);
            else if (i == 1)
                printf("%c", ch);
            else if (i < 4 && i > 0 && r > 3) {
                printf("%c", ch);
            }

            else if (i == 4 && r < 5) {
                printf("%c", ch);
            }
            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter Q
void q(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");
        for (int o = 0; o < 8; o++) {
            if (o == i)
                printf("%c", ch);

            else if (i == 0
                     && (o <= 1 || o >= 6 - i))
                printf(" ");
            else if (i == 1
                     && (o == 0 || o == 8 - i
                         || (o < 6 && o > 1)))
                printf(" ");
            else if (i == 2
                     && (o == 1 || o == 8 - i
                         || (o < 6 && o > 1)))
                printf(" ");
            else if ((i == 3 || i == 4 || i == 5)
                     && (o > 0 && o < 7))
                printf(" ");
            else if (i == 6
                     && (o == 0 || o == 8 + 5 - i
                         || (o < 6 && o > 1)))
                printf(" ");
            else if (i == 7
                     && (o <= 1 || o >= 6 - i + 7))
                printf(" ");
            else {
                printf("%c", ch);
            }
        }
        printf("\n");
    }
}

// Function to print the letter R
void r(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");
        {
            printf("%c%c", ch, ch);
        }

        for (int r = 0; r < 6; r++) {
            if (i == 0 && r < 5)
                printf("%c", ch);
            else if (i == 1)
                printf("%c", ch);
            else if (i < 4 && i > 0
                     && r > 3) {
                printf("%c", ch);
            }

            else if (i >= 4) {
                if (i == 4
                    && (r == 3 || r == 4)) {
                    printf("%c", ch);
                }

                else if (r == i - 2
                         || r == i - 3) {
                    printf("%c", ch);
                }
                else
                    printf(" ");
            }
            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter S
void s(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");
        for (int j = 0; j < 7; j++) {
            if (i == 0 && j > 0) {
                printf("%c", ch);
            }
            else if (i > 0 && i < 3
                     && j < 2) {
                printf("%c", ch);
            }
            else if (i == 3 && j > 0
                     && j < 6) {
                printf("%c", ch);
            }
            else if (i > 3 && i < 6
                     && j > 4) {
                printf("%c", ch);
            }
            else if (i == 6 && j < 6) {
                printf("%c", ch);
            }

            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter T
void t(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {

        printf(" ");
        for (int t = 0; t < 8; t++) {

            if (i < 2 && t < 8) {
                printf("%c", ch);
            }

            if (i > 1 && t < 3)
                printf(" ");
            if (i > 1 && t > 2
                && t < 5) {
                printf("%c", ch);
            }
            if (i > 1 && t > 4)
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter U
void u(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");

        for (int h = 0; h < 8; h++) {
            if (i < 7 && (h < 2 || h > 5)) {
                printf("%c", ch);
            }
            else if (i == 7
                     && (h == 0 || h == 7))
                printf(" ");
            else if (i > 5) {
                printf("%c", ch);
            }
            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter V
void v(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");
        for (int v = 0; v < 8; v++)
            if ((v == 0 || v == 7)
                && i < 4) {
                printf("%c", ch);
            }
            else if ((v == i - 4 || v == 11 - i)
                     && i >= 4) {
                printf("%c", ch);
            }
            else
                printf(" ");
        printf("\n");
    }
}

// Function to print the letter W
void w(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");
        for (int j = 0; j < 8; j++) {
            if (j == 0 || j == 7) {
                printf("%c", ch);
            }
            else if (i > 3
                     && (j == 7 - i || j == i)) {
                printf("%c", ch);
            }
            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter X
void x(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");
        for (int m = 0; m < 8; m++) {
            if (i == m || m == 7 - i) {
                printf("%c", ch);
            }
            else
                printf(" ");
        }

        printf("\n");
    }
}

// Function to print the letter Y
void y(void)
{
    printf("\n");
    for (int i = 0; i < 8; i++) {
        printf(" ");

        for (int y = 0; y < 8; y++) {
            if (i < 4) {
                if (y == i || y == i + 1
                    || y == 6 - i || y == 7 - i) {
                    printf("%c", ch);
                }
                else
                    printf(" ");
            }
            else if (y == 3 || y == 4) {
                printf("%c", ch);
            }
            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the letter Z
void z(void)
{
    printf("\n");

    for (int i = 0; i < 8; i++) {
        printf(" ");
        for (int j = 0; j < 8; j++) {
            if (i == 0 || i == 7) {
                printf("%c", ch);
            }
            else if (j == 7 - i) {
                printf("%c", ch);
            }
            else
                printf(" ");
        }
        printf("\n");
    }
}

// Function to print the required pattern
// by taking out each characters in it
void printPattern(char* str)
{

    int in = 0;

    while (str[in]) {

        char ch = str[in];
        if (ch < 95)
            ch = ch + 32;
        switch (ch) {
        case 'a':
            a();
            break;
        case 'b':
            b();
            break;
        case 'c':
            c();
            break;
        case 'd':
            d();
            break;
        case 'e':
            e();
            break;
        case 'f':
            f();
            break;
        case 'g':
            g();
            break;
        case 'h':
            h();
            break;
        case 'i':
            i();
            break;
        case 'j':
            j();
            break;
        case 'k':
            k();
            break;
        case 'l':
            l();
            break;
        case 'm':
            m();
            break;
        case 'n':
            n();
            break;
        case 'o':
            o();
            break;
        case 'p':
            p();
            break;
        case 'q':
            q();
            break;
        case 'r':
            r();
            break;
        case 's':
            s();
            break;
        case 't':
            t();
            break;
        case 'u':
            u();
            break;
        case 'v':
            v();
            break;
        case 'w':
            w();
            break;
        case 'x':
            x();
            break;
        case 'y':
            y();
            break;
        case 'z':
            z();
            break;
        default:
            break;
        }
        in++;
    }
}

// Driver code
int main()
{
    ch = '*';
    char* str = "GFG";
    printPattern(str);

    return 0;
}
Java
// Java Program to print the Alphabets
// of a Given Word using * pattern
class GFG{
 
static char ch;
 
// Function to print the letter A
static void a()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
        for (int a = 0; a < 8; a++) {
            if (i == 0 && (a == 0 || a == 7))
                System.out.printf(" ");
            else if (a < 2 || a > 5) {
                System.out.printf("%c", ch);
            }
            else if (i < 2 || (i > 3 && i < 5)) {
                System.out.printf("%c", ch);
            }
 
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter B
static void b()
{
    System.out.printf("\n");
    for (int i = 0; i < 9; i++) {
        System.out.printf(" %c%c", ch, ch);
 
        for (int r = 0; r < 6; r++) {
            if (i == 0 && r < 5)
                System.out.printf("%c", ch);
            else if (i == 1)
                System.out.printf("%c", ch);
            else if (i < 4 && i > 0
                     && r > 3) {
                System.out.printf("%c", ch);
            }
 
            else if (i == 4 && r < 5) {
                System.out.printf("%c", ch);
            }
            else if (i > 4 && i < 7
                     && r > 3) {
                System.out.printf("%c", ch);
            }
            else if (i == 7) {
                System.out.printf("%c", ch);
            }
            else if (i == 8 && r < 5) {
                System.out.printf("%c", ch);
            }
 
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter C
static void c()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
 
        System.out.printf(" ");
        for (int o = 0; o < 8; o++) {
            if (i == 0 && (o <= 1))
                System.out.printf(" ");
            else if (i == 1
                     && (o == 0 || o == 8 - i
                         || (o > 1)))
                System.out.printf(" ");
            else if (i == 2
                     && (o == 1 || o == 8 - i
                         || (o > 1)))
                System.out.printf(" ");
            else if ((i == 3 || i == 4
                      || i == 5)
                     && (o > 0))
                System.out.printf(" ");
            else if (i == 6
                     && (o == 0 || o == 8 + 5 - i
                         || (o > 1)))
                System.out.printf(" ");
            else if (i == 7
                     && (o <= 1))
                System.out.printf(" ");
            else {
                System.out.printf("%c", ch);
            }
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter D
static void d()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        {
            System.out.printf(" %c", ch);
        }
 
        for (int o = 0; o < 8; o++) {
            if (i == 0 && (o >= 6 - i))
                System.out.printf(" ");
            else if (i == 1
                     && (o == 0 || o == 8 - i
                         || (o < 6)))
                System.out.printf(" ");
            else if (i == 2
                     && (o == 1 || o == 8 - i
                         || (o < 6)))
                System.out.printf(" ");
            else if ((i == 3 || i == 4
                      || i == 5)
                     && (o < 7))
                System.out.printf(" ");
            else if (i == 6
                     && (o == 0 || o == 8 + 5 - i
                         || (o < 6)))
                System.out.printf(" ");
            else if (i == 7
                     && (o >= 6 - i + 7))
                System.out.printf(" ");
            else {
                System.out.printf("%c", ch);
            }
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter E
static void e()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
        for (int j = 0; j < 7; j++) {
            if (i == 0) {
                System.out.printf("%c", ch);
            }
            else if (i > 0 && i < 3
                     && j < 2) {
                System.out.printf("%c", ch);
            }
            else if (i == 3 && j < 6) {
                System.out.printf("%c", ch);
            }
            else if (i > 3 && i < 6
                     && j < 2) {
                System.out.printf("%c", ch);
            }
            else if (i == 6) {
                System.out.printf("%c", ch);
            }
 
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter F
static void f()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
        for (int j = 0; j < 7; j++) {
            if (i == 0) {
                System.out.printf("%c", ch);
            }
            else if (i > 0 && i < 3
                     && j < 2) {
                System.out.printf("%c", ch);
            }
            else if (i == 3 && j < 6) {
                System.out.printf("%c", ch);
            }
            else if (i > 3 && i < 7
                     && j < 2) {
                System.out.printf("%c", ch);
            }
 
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter G
static void g()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
 
        System.out.printf(" ");
        for (int o = 0; o < 8; o++) {
            if (i == 4 && o > 3
                || (o == 4 || o == 7)
                       && i > 4) {
                System.out.printf("%c", ch);
            }
 
            else if (i == 0 && (o <= 1))
                System.out.printf(" ");
            else if (i == 1
                     && (o == 0 || o == 8 - i
                         || (o > 1)))
                System.out.printf(" ");
            else if (i == 2
                     && (o == 1 || o == 8 - i
                         || (o > 1)))
                System.out.printf(" ");
            else if ((i == 3 || i == 4
                      || i == 5)
                     && (o > 0))
                System.out.printf(" ");
            else if (i == 6
                     && (o == 0 || (o > 1)))
                System.out.printf(" ");
            else if (i == 7
                     && (o <= 1 || o == 5
                         || o == 6))
                System.out.printf(" ");
            else {
                System.out.printf("%c", ch);
            }
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter H
static void h()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
        for (int h = 0; h < 8; h++) {
            if (h < 2 || h > 5) {
                System.out.printf("%c", ch);
            }
            else if (i > 2 && i < 5) {
                System.out.printf("%c", ch);
            }
 
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter I
static void i()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
 
        System.out.printf(" ");
 
        for (int t = 0; t < 8; t++) {
 
            if ((i < 1 || i > 6)
                && t < 8) {
                System.out.printf("%c", ch);
            }
 
            else if (i > 0 && t < 3)
                System.out.printf(" ");
            else if (i > 0 && t > 2
                     && t < 5) {
                System.out.printf("%c", ch);
            }
            else if (i > 0 && t > 4)
                System.out.printf(" ");
            else {
            }
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter J
static void j()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
 
        for (int h = 0; h < 8; h++) {
            if (i < 1) {
                System.out.printf("%c", ch);
            }
            else if (i == 5 && h < 1) {
                System.out.printf("%c", ch);
            }
            else if (i < 7 && h > 5) {
                System.out.printf("%c", ch);
            }
            else if (i == 7
                     && (h == 0 || h == 7))
                System.out.printf(" ");
            else if (i > 5) {
                System.out.printf("%c", ch);
            }
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter K
static void k()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
 
        for (int k1 = 0; k1 < 7; k1++) {
            if (k1 < 2) {
                System.out.printf("%c", ch);
            }
            else if ((k1 >= 5 - i)
                     && (k1 <= 6 - i)) {
                System.out.printf("%c", ch);
            }
 
            else if (i >= 4) {
                if (k1 == i - 2 || k1 == i - 1) {
                    System.out.printf("%c", ch);
                }
                else
                    System.out.printf(" ");
            }
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter L
static void l()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
 
        {
            System.out.printf("%c%c", ch, ch);
        }
        if (i == 6) {
            {
                System.out.printf("%c%c", ch, ch);
            }
            {
                System.out.printf("%c%c", ch, ch);
            }
            System.out.printf("%c%c", ch, ch);
        }
        if (i == 7) {
            {
                System.out.printf("%c%c", ch, ch);
            }
            {
                System.out.printf("%c%c", ch, ch);
            }
            System.out.printf("%c%c", ch, ch);
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter M
static void m()
{
    System.out.printf("\n");
 
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
        for (int j = 0; j < 8; j++) {
            if (j == 0 || j == 7) {
                System.out.printf("%c", ch);
            }
            else if (i < 4
                     && (j == 7 - i || j == i)) {
                System.out.printf("%c", ch);
            }
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter N
static void n()
{
    System.out.printf("\n");
 
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
        for (int n = 0; n < 8; n++) {
            if (n < 2 || n > 5) {
                System.out.printf("%c", ch);
            }
            else if (i == n - 1
                     || i == n + 1 || i == n) {
                System.out.printf("%c", ch);
            }
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter O
static void o()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
        for (int o = 0; o < 8; o++) {
            if (i == 0 && (o <= 1 || o >= 6 - i))
                System.out.printf(" ");
            else if (i == 1
                     && (o == 0 || o == 8 - i
                         || (o < 6 && o > 1)))
                System.out.printf(" ");
            else if (i == 2
                     && (o == 1 || o == 8 - i
                         || (o < 6 && o > 1)))
                System.out.printf(" ");
            else if ((i == 3 || i == 4 || i == 5)
                     && (o > 0 && o < 7))
                System.out.printf(" ");
            else if (i == 6
                     && (o == 0 || o == 8 + 5 - i
                         || (o < 6 && o > 1)))
                System.out.printf(" ");
            else if (i == 7
                     && (o <= 1 || o >= 6 - i + 7))
                System.out.printf(" ");
            else {
                System.out.printf("%c", ch);
            }
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter P
static void p()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
        {
            System.out.printf("%c%c", ch, ch);
        }
 
        for (int r = 0; r < 6; r++) {
            if (i == 0 && r < 5)
                System.out.printf("%c", ch);
            else if (i == 1)
                System.out.printf("%c", ch);
            else if (i < 4 && i > 0 && r > 3) {
                System.out.printf("%c", ch);
            }
 
            else if (i == 4 && r < 5) {
                System.out.printf("%c", ch);
            }
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter Q
static void q()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
        for (int o = 0; o < 8; o++) {
            if (o == i)
                System.out.printf("%c", ch);
 
            else if (i == 0
                     && (o <= 1 || o >= 6 - i))
                System.out.printf(" ");
            else if (i == 1
                     && (o == 0 || o == 8 - i
                         || (o < 6 && o > 1)))
                System.out.printf(" ");
            else if (i == 2
                     && (o == 1 || o == 8 - i
                         || (o < 6 && o > 1)))
                System.out.printf(" ");
            else if ((i == 3 || i == 4 || i == 5)
                     && (o > 0 && o < 7))
                System.out.printf(" ");
            else if (i == 6
                     && (o == 0 || o == 8 + 5 - i
                         || (o < 6 && o > 1)))
                System.out.printf(" ");
            else if (i == 7
                     && (o <= 1 || o >= 6 - i + 7))
                System.out.printf(" ");
            else {
                System.out.printf("%c", ch);
            }
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter R
static void r()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
        {
            System.out.printf("%c%c", ch, ch);
        }
 
        for (int r = 0; r < 6; r++) {
            if (i == 0 && r < 5)
                System.out.printf("%c", ch);
            else if (i == 1)
                System.out.printf("%c", ch);
            else if (i < 4 && i > 0
                     && r > 3) {
                System.out.printf("%c", ch);
            }
 
            else if (i >= 4) {
                if (i == 4
                    && (r == 3 || r == 4)) {
                    System.out.printf("%c", ch);
                }
 
                else if (r == i - 2
                         || r == i - 3) {
                    System.out.printf("%c", ch);
                }
                else
                    System.out.printf(" ");
            }
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter S
static void s()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
        for (int j = 0; j < 7; j++) {
            if (i == 0 && j > 0) {
                System.out.printf("%c", ch);
            }
            else if (i > 0 && i < 3
                     && j < 2) {
                System.out.printf("%c", ch);
            }
            else if (i == 3 && j > 0
                     && j < 6) {
                System.out.printf("%c", ch);
            }
            else if (i > 3 && i < 6
                     && j > 4) {
                System.out.printf("%c", ch);
            }
            else if (i == 6 && j < 6) {
                System.out.printf("%c", ch);
            }
 
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter T
static void t()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
 
        System.out.printf(" ");
        for (int t = 0; t < 8; t++) {
 
            if (i < 2 && t < 8) {
                System.out.printf("%c", ch);
            }
 
            if (i > 1 && t < 3)
                System.out.printf(" ");
            if (i > 1 && t > 2
                && t < 5) {
                System.out.printf("%c", ch);
            }
            if (i > 1 && t > 4)
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter U
static void u()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
 
        for (int h = 0; h < 8; h++) {
            if (i < 7 && (h < 2 || h > 5)) {
                System.out.printf("%c", ch);
            }
            else if (i == 7
                     && (h == 0 || h == 7))
                System.out.printf(" ");
            else if (i > 5) {
                System.out.printf("%c", ch);
            }
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter V
static void v()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
        for (int v = 0; v < 8; v++)
            if ((v == 0 || v == 7)
                && i < 4) {
                System.out.printf("%c", ch);
            }
            else if ((v == i - 4 || v == 11 - i)
                     && i >= 4) {
                System.out.printf("%c", ch);
            }
            else
                System.out.printf(" ");
        System.out.printf("\n");
    }
}
 
// Function to print the letter W
static void w()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
        for (int j = 0; j < 8; j++) {
            if (j == 0 || j == 7) {
                System.out.printf("%c", ch);
            }
            else if (i > 3
                     && (j == 7 - i || j == i)) {
                System.out.printf("%c", ch);
            }
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter X
static void x()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
        for (int m = 0; m < 8; m++) {
            if (i == m || m == 7 - i) {
                System.out.printf("%c", ch);
            }
            else
                System.out.printf(" ");
        }
 
        System.out.printf("\n");
    }
}
 
// Function to print the letter Y
static void y()
{
    System.out.printf("\n");
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
 
        for (int y = 0; y < 8; y++) {
            if (i < 4) {
                if (y == i || y == i + 1
                    || y == 6 - i || y == 7 - i) {
                    System.out.printf("%c", ch);
                }
                else
                    System.out.printf(" ");
            }
            else if (y == 3 || y == 4) {
                System.out.printf("%c", ch);
            }
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the letter Z
static void z()
{
    System.out.printf("\n");
 
    for (int i = 0; i < 8; i++) {
        System.out.printf(" ");
        for (int j = 0; j < 8; j++) {
            if (i == 0 || i == 7) {
                System.out.printf("%c", ch);
            }
            else if (j == 7 - i) {
                System.out.printf("%c", ch);
            }
            else
                System.out.printf(" ");
        }
        System.out.printf("\n");
    }
}
 
// Function to print the required pattern
// by taking out each characters in it
static void printPattern(char[] str)
{
 
    int in = 0;
 
    while (in<str.length) {
 
        char ch = str[in];
        if (ch < 95)
            ch = (char) (ch + 32);
        switch (ch) {
        case 'a':
            a();
            break;
        case 'b':
            b();
            break;
        case 'c':
            c();
            break;
        case 'd':
            d();
            break;
        case 'e':
            e();
            break;
        case 'f':
            f();
            break;
        case 'g':
            g();
            break;
        case 'h':
            h();
            break;
        case 'i':
            i();
            break;
        case 'j':
            j();
            break;
        case 'k':
            k();
            break;
        case 'l':
            l();
            break;
        case 'm':
            m();
            break;
        case 'n':
            n();
            break;
        case 'o':
            o();
            break;
        case 'p':
            p();
            break;
        case 'q':
            q();
            break;
        case 'r':
            r();
            break;
        case 's':
            s();
            break;
        case 't':
            t();
            break;
        case 'u':
            u();
            break;
        case 'v':
            v();
            break;
        case 'w':
            w();
            break;
        case 'x':
            x();
            break;
        case 'y':
            y();
            break;
        case 'z':
            z();
            break;
        default:
            break;
        }
        in++;
    }
}
 
// Driver code
public static void main(String[] args)
{
    ch = '*';
    char[] str = "GFG".toCharArray();
    printPattern(str);
 
}
}

// This code contributed by Rajput-Ji
Python3
def a():
    for i in range(8):
        print(" ", end="")
        for a in range(8):
            if i == 0 and (a == 0 or a == 7):
                print(" ", end="")
            elif a < 2 or a > 5:
                print(ch, end="")
            elif i < 2 or (i > 3 and i < 5):
                print(ch, end="")
            else:
                print(" ", end="")
        print()

def b():
    for i in range(9):
        print(ch + ch, end="")
        for r in range(6):
            if i == 0 and r < 5:
                print(ch, end="")
            elif i == 1:
                print(ch, end="")
            elif i < 4 and i > 0 and r > 3:
                print(ch, end="")
            elif i == 4 and r < 5:
                print(ch, end="")
            elif i > 4 and i < 7 and r > 3:
                print(ch, end="")
            elif i == 7:
                print(ch, end="")
            elif i == 8 and r < 5:
                print(ch, end="")
            else:
                print(" ", end="")
        print()

def c():
    for i in range(8):
        print(" ", end="")
        for o in range(8):
            if i == 0 and (o <= 1):
                print(" ", end="")
            elif i == 1 and (o == 0 or o == 8 - i or (o > 1)):
                print(" ", end="")
            elif i == 2 and (o == 1 or o == 8 - i or (o > 1)):
                print(" ", end="")
            elif (i == 3 or i == 4 or i == 5) and (o > 0):
                print(" ", end="")
            elif i == 6 and (o == 0 or o == 8 + 5 - i or (o > 1)):
                print(" ", end="")
            elif i == 7 and (o <= 1):
                print(" ", end="")
            else:
                print(ch, end="")
        print()

def d():
    for i in range(8):
        print(" " + ch, end="")
        for o in range(8):
            if i == 0 and (o >= 6 - i):
                print(" ", end="")
            elif i == 1 and (o == 0 or o == 8 - i or (o < 6)):
                print(" ", end="")
            elif i == 2 and (o == 1 or o == 8 - i or (o < 6)):
                print(" ", end="")
            elif (i == 3 or i == 4 or i == 5) and (o < 7):
                print(" ", end="")
            elif i == 6 and (o == 0 or o == 8 + 5 - i or (o < 6)):
                print(" ", end="")
            elif i == 7 and (o >= 6 - i + 7):
                print(" ", end="")
            else:
                print(ch, end="")
        print()

# Function to print the letter E
def e():
    print()
    for i in range(8):
        print(" ", end="")
        for j in range(7):
            if i == 0:
                print(ch, end="")
            elif i > 0 and i < 3 and j < 2:
                print(ch, end="")
            elif i == 3 and j < 6:
                print(ch, end="")
            elif i > 3 and i < 6 and j < 2:
                print(ch, end="")
            elif i == 6:
                print(ch, end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter F
def f():
    print()
    for i in range(8):
        print(" ", end="")
        for j in range(7):
            if i == 0:
                print(ch, end="")
            elif i > 0 and i < 3 and j < 2:
                print(ch, end="")
            elif i == 3 and j < 6:
                print(ch, end="")
            elif i > 3 and i < 7 and j < 2:
                print(ch, end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter G
def g():
    print()
    for i in range(8):
        print(" ", end="")
        for o in range(8):
            if i == 4 and o > 3 or (o == 4 or o == 7) and i > 4:
                print(ch, end="")
            elif i == 0 and o <= 1:
                print(" ", end="")
            elif i == 1 and (o == 0 or o == 8 - i or o > 1):
                print(" ", end="")
            elif i == 2 and (o == 1 or o == 8 - i or o > 1):
                print(" ", end="")
            elif (i == 3 or i == 4 or i == 5) and o > 0:
                print(" ", end="")
            elif i == 6 and (o == 0 or o > 1):
                print(" ", end="")
            elif i == 7 and (o <= 1 or o == 5 or o == 6):
                print(" ", end="")
            else:
                print(ch, end="")
        print()

# Function to print the letter H
def h():
    print()
    for i in range(8):
        print(" ", end="")
        for j in range(7):
            if j == 0 or j == 6:
                print(ch, end="")
            elif i == 3:
                print(ch, end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter I
def i():
    print()
    for i in range(8):
        print(" ", end="")
        for j in range(7):
            if i == 0 or i == 7:
                print(ch, end="")
            elif j == 3:
                print(ch, end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter J
def j():
    print()
    for i in range(8):
        print(" ", end="")
        for h in range(8):
            if i < 1:
                print(ch, end="")
            elif i == 5 and h < 1:
                print(ch, end="")
            elif i < 7 and h > 5:
                print(ch, end="")
            elif i == 7 and (h == 0 or h == 7):
                print(" ", end="")
            elif i > 5:
                print(ch, end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter K
def k():
    print()
    for i in range(8):
        print(" ", end="")
        for k1 in range(7):
            if k1 < 2:
                print(ch, end="")
            elif k1 >= 5 - i and k1 <= 6 - i:
                print(ch, end="")
            elif i >= 4:
                if k1 == i - 2 or k1 == i - 1:
                    print(ch, end="")
                else:
                    print(" ", end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter L
def l():
    print()
    for i in range(8):
        print(" ", end="")
        if i == 6 or i == 7:
            print(ch*2, end="")
            print(ch*2, end="")
            print(ch, end="")
        else:
            print(ch*2, end="")
        print()

# Function to print the letter M
def m():
    print()
    for i in range(8):
        print(" ", end="")
        for j in range(8):
            if j == 0 or j == 7:
                print(ch, end="")
            elif i < 4 and (j == 7 - i or j == i):
                print(ch, end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter N
def n():
    print()
    for i in range(8):
        print(" ", end="")
        for n in range(8):
            if n < 2 or n > 5:
                print(ch, end="")
            elif i == n - 1 or i == n + 1 or i == n:
                print(ch, end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter O
def o():
    print()
    for i in range(8):
        print(" ", end="")
        for o in range(8):
            if i == 0 and (o <= 1 or o >= 6 - i):
                print(" ", end="")
            elif i == 1 and (o == 0 or o == 8 - i or (o < 6 and o > 1)):
                print(" ", end="")
            elif i == 2 and (o == 1 or o == 8 - i or (o < 6 and o > 1)):
                print(" ", end="")
            elif i in [3, 4, 5] and (o > 0 and o < 7):
                print(" ", end="")
            elif i == 6 and (o > 1 and o < 6):
                print(ch, end="")
            elif i == 7 and (o > 2 and o < 5):
                print(ch, end="")
            else:
                print(ch, end="")
        print()
# Function to print the letter P
def p():
    print()
    for i in range(8):
        print(" ", end="")
        for r in range(6):
            if (i == 0 and r < 5) or (i == 1):
                print(ch, end="")
            elif (i < 4 and i > 0 and r > 3) or (i == 4 and r < 5):
                print(ch, end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter Q
def q():
    print()
    for i in range(8):
        print(" ", end="")
        for o in range(8):
            if o == i:
                print(ch, end="")
            elif (i == 0 and (o <= 1 or o >= 6 - i)) or (i == 1 and (o == 0 or o == 8 - i or (o < 6 and o > 1))) or (i == 2 and (o == 1 or o == 8 - i or (o < 6 and o > 1))) or ((i == 3 or i == 4 or i == 5) and (o > 0 and o < 7)) or (i == 6 and (o == 0 or o == 8 + 5 - i or (o < 6 and o > 1))) or (i == 7 and (o <= 1 or o >= 6 - i + 7)):
                print(" ", end="")
            else:
                print(ch, end="")
        print()

# Function to print the letter R
def r():
    print()
    for i in range(8):
        print(" ", end="")
        for r in range(6):
            if (i == 0 and r < 5) or (i == 1) or (i < 4 and i > 0 and r > 3):
                print(ch, end="")
            elif i >= 4:
                if i == 4 and (r == 3 or r == 4):
                    print(ch, end="")
                elif r == i - 2 or r == i - 3:
                    print(ch, end="")
                else:
                    print(" ", end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter S
def s():
    print()
    for i in range(8):
        print(" ", end="")
        for j in range(7):
            if i == 0 and j > 0:
                print(ch, end="")
            elif i > 0 and i < 3 and j < 2:
                print(ch, end="")
            elif i == 3 and j > 0 and j < 6:
                print(ch, end="")
            elif i > 3 and i < 6 and j > 4:
                print(ch, end="")
            elif i == 6 and j < 6:
                print(ch, end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter T
def t():
    print()
    for i in range(8):
        if i == 0:
            for j in range(7):
                if j != 3:
                    print(ch, end="")
                else:
                    print(" ", end="")
        else:
            print(" ", end="")
            print(ch, end="")
        print()
# Function to print the letter U
def u():
    print()
    for i in range(8):
        print(" ", end="")
        for h in range(8):
            if i < 7 and (h < 2 or h > 5):
                print(ch, end="")
            elif i == 7 and (h == 0 or h == 7):
                print(" ", end="")
            elif i > 5:
                print(ch, end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter V
def v():
    print()
    for i in range(8):
        print(" ", end="")
        for v in range(8):
            if (v == 0 or v == 7) and i < 4:
                print(ch, end="")
            elif (v == i - 4 or v == 11 - i) and i >= 4:
                print(ch, end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter W
def w():
    print()
    for i in range(8):
        print(" ", end="")
        for j in range(8):
            if j == 0 or j == 7:
                print(ch, end="")
            elif i > 3 and (j == 7 - i or j == i):
                print(ch, end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter X
def x():
    print()
    for i in range(8):
        print(" ", end="")
        for m in range(8):
            if i == m or m == 7 - i:
                print(ch, end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter Y
def y():
    print()
    for i in range(8):
        print(" ", end="")
        for y in range(8):
            if i < 4:
                if y == i or y == i + 1 or y == 6 - i or y == 7 - i:
                    print(ch, end="")
                else:
                    print(" ", end="")
            elif y == 3 or y == 4:
                print(ch, end="")
            else:
                print(" ", end="")
        print()

# Function to print the letter Z
def z():
    print()
    for i in range(8):
        print(" ", end="")
        for j in range(8):
            if i == 0 or i == 7:
                print(ch, end="")
            elif j == 7 - i:
                print(ch, end="")
            else:
                print(" ", end="")
        print()
        
def printPattern(str):
    in_ = 0
    while in_ < len(str):
        ch = str[in_]
        if ch < 'a':
            ch = chr(ord(ch) + 32)
        if ch == 'a':
            a()
        elif ch == 'b':
            b()
        elif ch == 'c':
            c()
        elif ch == 'd':
            d()
        elif ch == 'e':
            e()
        elif ch == 'f':
            f()
        elif ch == 'g':
            g()
        elif ch == 'h':
            h()
        elif ch == 'i':
            i()
        elif ch == 'j':
            j()
        elif ch == 'k':
            k()
        elif ch == 'l':
            l()
        elif ch == 'm':
            m()
        elif ch == 'n':
            n()
        elif ch == 'o':
            o()
        elif ch == 'p':
            p()
        elif ch == 'q':
            q()
        elif ch == 'r':
            r()
        elif ch == 's':
            s()
        elif ch == 't':
            t()
        elif ch == 'u':
            u()
        elif ch == 'v':
            v()
        elif ch == 'w':
            w()
        elif ch == 'x':
            x()
        elif ch == 'y':
            y()
        elif ch == 'z':
            z()
        in_ += 1

# Driver code
ch = '*'
str = "GFG"
printPattern(str)
C#
// C# Program to print the Alphabets
// of a Given Word using * pattern
using System;

class GFG{

static char ch;

// Function to print the letter A
static void a()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");
        for (int a = 0; a < 8; a++) {
            if (i == 0 && (a == 0 || a == 7))
                Console.Write(" ");
            else if (a < 2 || a > 5) {
                Console.Write("{0}", ch);
            }
            else if (i < 2 || (i > 3 && i < 5)) {
                Console.Write("{0}", ch);
            }

            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter B
static void b()
{
    Console.Write("\n");
    for (int i = 0; i < 9; i++) {
        Console.Write(" {0}{0}", ch, ch);

        for (int r = 0; r < 6; r++) {
            if (i == 0 && r < 5)
                Console.Write("{0}", ch);
            else if (i == 1)
                Console.Write("{0}", ch);
            else if (i < 4 && i > 0
                    && r > 3) {
                Console.Write("{0}", ch);
            }

            else if (i == 4 && r < 5) {
                Console.Write("{0}", ch);
            }
            else if (i > 4 && i < 7
                    && r > 3) {
                Console.Write("{0}", ch);
            }
            else if (i == 7) {
                Console.Write("{0}", ch);
            }
            else if (i == 8 && r < 5) {
                Console.Write("{0}", ch);
            }

            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter C
static void c()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {

        Console.Write(" ");
        for (int o = 0; o < 8; o++) {
            if (i == 0 && (o <= 1))
                Console.Write(" ");
            else if (i == 1
                    && (o == 0 || o == 8 - i
                        || (o > 1)))
                Console.Write(" ");
            else if (i == 2
                    && (o == 1 || o == 8 - i
                        || (o > 1)))
                Console.Write(" ");
            else if ((i == 3 || i == 4
                    || i == 5)
                    && (o > 0))
                Console.Write(" ");
            else if (i == 6
                    && (o == 0 || o == 8 + 5 - i
                        || (o > 1)))
                Console.Write(" ");
            else if (i == 7
                    && (o <= 1))
                Console.Write(" ");
            else {
                Console.Write("{0}", ch);
            }
        }
        Console.Write("\n");
    }
}

// Function to print the letter D
static void d()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        {
            Console.Write(" {0}", ch);
        }

        for (int o = 0; o < 8; o++) {
            if (i == 0 && (o >= 6 - i))
                Console.Write(" ");
            else if (i == 1
                    && (o == 0 || o == 8 - i
                        || (o < 6)))
                Console.Write(" ");
            else if (i == 2
                    && (o == 1 || o == 8 - i
                        || (o < 6)))
                Console.Write(" ");
            else if ((i == 3 || i == 4
                    || i == 5)
                    && (o < 7))
                Console.Write(" ");
            else if (i == 6
                    && (o == 0 || o == 8 + 5 - i
                        || (o < 6)))
                Console.Write(" ");
            else if (i == 7
                    && (o >= 6 - i + 7))
                Console.Write(" ");
            else {
                Console.Write("{0}", ch);
            }
        }
        Console.Write("\n");
    }
}

// Function to print the letter E
static void e()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");
        for (int j = 0; j < 7; j++) {
            if (i == 0) {
                Console.Write("{0}", ch);
            }
            else if (i > 0 && i < 3
                    && j < 2) {
                Console.Write("{0}", ch);
            }
            else if (i == 3 && j < 6) {
                Console.Write("{0}", ch);
            }
            else if (i > 3 && i < 6
                    && j < 2) {
                Console.Write("{0}", ch);
            }
            else if (i == 6) {
                Console.Write("{0}", ch);
            }

            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter F
static void f()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");
        for (int j = 0; j < 7; j++) {
            if (i == 0) {
                Console.Write("{0}", ch);
            }
            else if (i > 0 && i < 3
                    && j < 2) {
                Console.Write("{0}", ch);
            }
            else if (i == 3 && j < 6) {
                Console.Write("{0}", ch);
            }
            else if (i > 3 && i < 7
                    && j < 2) {
                Console.Write("{0}", ch);
            }

            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter G
static void g()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {

        Console.Write(" ");
        for (int o = 0; o < 8; o++) {
            if (i == 4 && o > 3
                || (o == 4 || o == 7)
                    && i > 4) {
                Console.Write("{0}", ch);
            }

            else if (i == 0 && (o <= 1))
                Console.Write(" ");
            else if (i == 1
                    && (o == 0 || o == 8 - i
                        || (o > 1)))
                Console.Write(" ");
            else if (i == 2
                    && (o == 1 || o == 8 - i
                        || (o > 1)))
                Console.Write(" ");
            else if ((i == 3 || i == 4
                    || i == 5)
                    && (o > 0))
                Console.Write(" ");
            else if (i == 6
                    && (o == 0 || (o > 1)))
                Console.Write(" ");
            else if (i == 7
                    && (o <= 1 || o == 5
                        || o == 6))
                Console.Write(" ");
            else {
                Console.Write("{0}", ch);
            }
        }
        Console.Write("\n");
    }
}

// Function to print the letter H
static void h()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");
        for (int h = 0; h < 8; h++) {
            if (h < 2 || h > 5) {
                Console.Write("{0}", ch);
            }
            else if (i > 2 && i < 5) {
                Console.Write("{0}", ch);
            }

            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter I
static void i()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {

        Console.Write(" ");

        for (int t = 0; t < 8; t++) {

            if ((i < 1 || i > 6)
                && t < 8) {
                Console.Write("{0}", ch);
            }

            else if (i > 0 && t < 3)
                Console.Write(" ");
            else if (i > 0 && t > 2
                    && t < 5) {
                Console.Write("{0}", ch);
            }
            else if (i > 0 && t > 4)
                Console.Write(" ");
            else {
            }
        }
        Console.Write("\n");
    }
}

// Function to print the letter J
static void j()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");

        for (int h = 0; h < 8; h++) {
            if (i < 1) {
                Console.Write("{0}", ch);
            }
            else if (i == 5 && h < 1) {
                Console.Write("{0}", ch);
            }
            else if (i < 7 && h > 5) {
                Console.Write("{0}", ch);
            }
            else if (i == 7
                    && (h == 0 || h == 7))
                Console.Write(" ");
            else if (i > 5) {
                Console.Write("{0}", ch);
            }
            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter K
static void k()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");

        for (int k1 = 0; k1 < 7; k1++) {
            if (k1 < 2) {
                Console.Write("{0}", ch);
            }
            else if ((k1 >= 5 - i)
                    && (k1 <= 6 - i)) {
                Console.Write("{0}", ch);
            }

            else if (i >= 4) {
                if (k1 == i - 2 || k1 == i - 1) {
                    Console.Write("{0}", ch);
                }
                else
                    Console.Write(" ");
            }
            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter L
static void l()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");

        {
            Console.Write("{0}{0}", ch, ch);
        }
        if (i == 6) {
            {
                Console.Write("{0}{0}", ch, ch);
            }
            {
                Console.Write("{0}{0}", ch, ch);
            }
            Console.Write("{0}{0}", ch, ch);
        }
        if (i == 7) {
            {
                Console.Write("{0}{0}", ch, ch);
            }
            {
                Console.Write("{0}{0}", ch, ch);
            }
            Console.Write("{0}{0}", ch, ch);
        }
        Console.Write("\n");
    }
}

// Function to print the letter M
static void m()
{
    Console.Write("\n");

    for (int i = 0; i < 8; i++) {
        Console.Write(" ");
        for (int j = 0; j < 8; j++) {
            if (j == 0 || j == 7) {
                Console.Write("{0}", ch);
            }
            else if (i < 4
                    && (j == 7 - i || j == i)) {
                Console.Write("{0}", ch);
            }
            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter N
static void n()
{
    Console.Write("\n");

    for (int i = 0; i < 8; i++) {
        Console.Write(" ");
        for (int n = 0; n < 8; n++) {
            if (n < 2 || n > 5) {
                Console.Write("{0}", ch);
            }
            else if (i == n - 1
                    || i == n + 1 || i == n) {
                Console.Write("{0}", ch);
            }
            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter O
static void o()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");
        for (int o = 0; o < 8; o++) {
            if (i == 0 && (o <= 1 || o >= 6 - i))
                Console.Write(" ");
            else if (i == 1
                    && (o == 0 || o == 8 - i
                        || (o < 6 && o > 1)))
                Console.Write(" ");
            else if (i == 2
                    && (o == 1 || o == 8 - i
                        || (o < 6 && o > 1)))
                Console.Write(" ");
            else if ((i == 3 || i == 4 || i == 5)
                    && (o > 0 && o < 7))
                Console.Write(" ");
            else if (i == 6
                    && (o == 0 || o == 8 + 5 - i
                        || (o < 6 && o > 1)))
                Console.Write(" ");
            else if (i == 7
                    && (o <= 1 || o >= 6 - i + 7))
                Console.Write(" ");
            else {
                Console.Write("{0}", ch);
            }
        }
        Console.Write("\n");
    }
}

// Function to print the letter P
static void p()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");
        {
            Console.Write("{0}{0}", ch, ch);
        }

        for (int r = 0; r < 6; r++) {
            if (i == 0 && r < 5)
                Console.Write("{0}", ch);
            else if (i == 1)
                Console.Write("{0}", ch);
            else if (i < 4 && i > 0 && r > 3) {
                Console.Write("{0}", ch);
            }

            else if (i == 4 && r < 5) {
                Console.Write("{0}", ch);
            }
            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter Q
static void q()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");
        for (int o = 0; o < 8; o++) {
            if (o == i)
                Console.Write("{0}", ch);

            else if (i == 0
                    && (o <= 1 || o >= 6 - i))
                Console.Write(" ");
            else if (i == 1
                    && (o == 0 || o == 8 - i
                        || (o < 6 && o > 1)))
                Console.Write(" ");
            else if (i == 2
                    && (o == 1 || o == 8 - i
                        || (o < 6 && o > 1)))
                Console.Write(" ");
            else if ((i == 3 || i == 4 || i == 5)
                    && (o > 0 && o < 7))
                Console.Write(" ");
            else if (i == 6
                    && (o == 0 || o == 8 + 5 - i
                        || (o < 6 && o > 1)))
                Console.Write(" ");
            else if (i == 7
                    && (o <= 1 || o >= 6 - i + 7))
                Console.Write(" ");
            else {
                Console.Write("{0}", ch);
            }
        }
        Console.Write("\n");
    }
}

// Function to print the letter R
static void r()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");
        {
            Console.Write("{0}{0}", ch, ch);
        }

        for (int r = 0; r < 6; r++) {
            if (i == 0 && r < 5)
                Console.Write("{0}", ch);
            else if (i == 1)
                Console.Write("{0}", ch);
            else if (i < 4 && i > 0
                    && r > 3) {
                Console.Write("{0}", ch);
            }

            else if (i >= 4) {
                if (i == 4
                    && (r == 3 || r == 4)) {
                    Console.Write("{0}", ch);
                }

                else if (r == i - 2
                        || r == i - 3) {
                    Console.Write("{0}", ch);
                }
                else
                    Console.Write(" ");
            }
            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter S
static void s()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");
        for (int j = 0; j < 7; j++) {
            if (i == 0 && j > 0) {
                Console.Write("{0}", ch);
            }
            else if (i > 0 && i < 3
                    && j < 2) {
                Console.Write("{0}", ch);
            }
            else if (i == 3 && j > 0
                    && j < 6) {
                Console.Write("{0}", ch);
            }
            else if (i > 3 && i < 6
                    && j > 4) {
                Console.Write("{0}", ch);
            }
            else if (i == 6 && j < 6) {
                Console.Write("{0}", ch);
            }

            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter T
static void t()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {

        Console.Write(" ");
        for (int t = 0; t < 8; t++) {

            if (i < 2 && t < 8) {
                Console.Write("{0}", ch);
            }

            if (i > 1 && t < 3)
                Console.Write(" ");
            if (i > 1 && t > 2
                && t < 5) {
                Console.Write("{0}", ch);
            }
            if (i > 1 && t > 4)
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter U
static void u()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");

        for (int h = 0; h < 8; h++) {
            if (i < 7 && (h < 2 || h > 5)) {
                Console.Write("{0}", ch);
            }
            else if (i == 7
                    && (h == 0 || h == 7))
                Console.Write(" ");
            else if (i > 5) {
                Console.Write("{0}", ch);
            }
            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter V
static void v()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");
        for (int v = 0; v < 8; v++)
            if ((v == 0 || v == 7)
                && i < 4) {
                Console.Write("{0}", ch);
            }
            else if ((v == i - 4 || v == 11 - i)
                    && i >= 4) {
                Console.Write("{0}", ch);
            }
            else
                Console.Write(" ");
        Console.Write("\n");
    }
}

// Function to print the letter W
static void w()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");
        for (int j = 0; j < 8; j++) {
            if (j == 0 || j == 7) {
                Console.Write("{0}", ch);
            }
            else if (i > 3
                    && (j == 7 - i || j == i)) {
                Console.Write("{0}", ch);
            }
            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter X
static void x()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");
        for (int m = 0; m < 8; m++) {
            if (i == m || m == 7 - i) {
                Console.Write("{0}", ch);
            }
            else
                Console.Write(" ");
        }

        Console.Write("\n");
    }
}

// Function to print the letter Y
static void y()
{
    Console.Write("\n");
    for (int i = 0; i < 8; i++) {
        Console.Write(" ");

        for (int y = 0; y < 8; y++) {
            if (i < 4) {
                if (y == i || y == i + 1
                    || y == 6 - i || y == 7 - i) {
                    Console.Write("{0}", ch);
                }
                else
                    Console.Write(" ");
            }
            else if (y == 3 || y == 4) {
                Console.Write("{0}", ch);
            }
            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the letter Z
static void z()
{
    Console.Write("\n");

    for (int i = 0; i < 8; i++) {
        Console.Write(" ");
        for (int j = 0; j < 8; j++) {
            if (i == 0 || i == 7) {
                Console.Write("{0}", ch);
            }
            else if (j == 7 - i) {
                Console.Write("{0}", ch);
            }
            else
                Console.Write(" ");
        }
        Console.Write("\n");
    }
}

// Function to print the required pattern
// by taking out each characters in it
static void printPattern(char[] str)
{

    int iN = 0;

    while (iN<str.Length) {

        char ch = str[iN];
        if (ch < 95)
            ch = (char) (ch + 32);
        switch (ch) {
        case 'a':
            a();
            break;
        case 'b':
            b();
            break;
        case 'c':
            c();
            break;
        case 'd':
            d();
            break;
        case 'e':
            e();
            break;
        case 'f':
            f();
            break;
        case 'g':
            g();
            break;
        case 'h':
            h();
            break;
        case 'i':
            i();
            break;
        case 'j':
            j();
            break;
        case 'k':
            k();
            break;
        case 'l':
            l();
            break;
        case 'm':
            m();
            break;
        case 'n':
            n();
            break;
        case 'o':
            o();
            break;
        case 'p':
            p();
            break;
        case 'q':
            q();
            break;
        case 'r':
            r();
            break;
        case 's':
            s();
            break;
        case 't':
            t();
            break;
        case 'u':
            u();
            break;
        case 'v':
            v();
            break;
        case 'w':
            w();
            break;
        case 'x':
            x();
            break;
        case 'y':
            y();
            break;
        case 'z':
            z();
            break;
        default:
            break;
        }
        iN++;
    }
}

// Driver code
public static void Main(String[] args)
{
    ch = '*';
    char[] str = "GFG".ToCharArray();
    printPattern(str);

}
}
// This code is contributed by 29AjayKumar
JavaScript
// Function to print the letter A
function a() {
    console.log();
    for (let i = 0; i < 8; i++) {
        console.log(" ");
        for (let a = 0; a < 8; a++) {
            if (i == 0 && (a == 0 || a == 7))
                console.log(" ");
            else if (a < 2 || a > 5) {
                console.log(ch);
            }
            else if (i < 2 || (i > 3 && i < 5)) {
                console.log(ch);
            }
            else
                console.log(" ");
        }
        console.log();
    }
}

// Function to print the letter B
function b() {
    console.log();
    for (let i = 0; i < 9; i++) {
        console.log(ch + ch);

        for (let r = 0; r < 6; r++) {
            if (i == 0 && r < 5)
                console.log(ch);
            else if (i == 1)
                console.log(ch);
            else if (i < 4 && i > 0 && r > 3) {
                console.log(ch);
            }

            else if (i == 4 && r < 5) {
                console.log(ch);
            }
            else if (i > 4 && i < 7 && r > 3) {
                console.log(ch);
            }
            else if (i == 7) {
                console.log(ch);
            }
            else if (i == 8 && r < 5) {
                console.log(ch);
            }

            else
                console.log(" ");
        }
        console.log();
    }
}

// Function to print the letter C
function c() {
    console.log();
    for (let i = 0; i < 8; i++) {
        console.log(" ");
        for (let o = 0; o < 8; o++) {
            if (i == 0 && (o <= 1))
                console.log(" ");
            else if (i == 1 && (o == 0 || o == 8 - i || (o > 1)))
                console.log(" ");
            else if (i == 2 && (o == 1 || o == 8 - i || (o > 1)))
                console.log(" ");
            else if ((i == 3 || i == 4 || i == 5) && (o > 0))
                console.log(" ");
            else if (i == 6 && (o == 0 || o == 8 + 5 - i || (o > 1)))
                console.log(" ");
            else if (i == 7 && (o <= 1))
                console.log(" ");
            else {
                console.log(ch);
            }
        }
        console.log();
    }
}

// Function to print the letter D
function d() {
    console.log();
    for (let i = 0; i < 8; i++) {
        {
            console.log(" " + ch);
        }

        for (let o = 0; o < 8; o++) {
            if (i == 0 && (o >= 6 - i))
                console.log(" ");
            else if (i == 1 && (o == 0 || o == 8 - i || (o < 6)))
                console.log(" ");
            else if (i == 2 && (o == 1 || o == 8 - i || (o < 6)))
                console.log(" ");
            else if ((i == 3 || i == 4 || i == 5) && (o < 7))
                console.log(" ");
            else if (i == 6 && (o == 0 || o == 8 + 5 - i || (o < 6)))
                console.log(" ");
            else if (i == 7 && (o >= 6 - i + 7))
                console.log(" ");
            else {
                console.log(ch);
            }
        }
        console.log();
    }
}

// Function to print the letter E
function e() {
    console.log();
    for (let i = 0; i < 8; i++) {
        console.log(" ");
        for (let j = 0; j < 7; j++) {
            if (i == 0) {
                console.log(ch);
            }
            else if (i > 0 && i < 3 && j < 2) {
                console.log(ch);
            }
            else if (i == 3 && j < 6) {
                console.log(ch);
            }
            else if (i > 3 && i < 6 && j < 2) {
                console.log(ch);
            }
            else if (i == 6) {
                console.log(ch);
            }

            else
                console.log(" ");
        }
        console.log();
    }
}

// Function to print the letter F
function f() {
    console.log();
    for (let i = 0; i < 8; i++) {
        console.log(" ");
        for (let j = 0; j < 7; j++) {
            if (i == 0) {
                console.log(ch);
            }
            else if (i > 0 && i < 3 && j < 2) {
                console.log(ch);
            }
            else if (i == 3 && j < 6) {
                console.log(ch);
            }
            else if (i > 3 && i < 7 && j < 2) {
                console.log(ch);
            }

            else
                console.log(" ");
        }
        console.log();
    }
}

// Function to print the letter G
function g() {
    console.log();
    for (let i = 0; i < 8; i++) {

        console.log(" ");
        for (let o = 0; o < 8; o++) {
            if (i == 4 && o > 3 || (o == 4 || o == 7) && i > 4) {
                console.log(ch);
            }

            else if (i == 0 && (o <= 1))
                console.log(" ");
            else if (i == 1 && (o == 0 || o == 8 - i || (o > 1)))
                console.log(" ");
            else if (i == 2 && (o == 1 || o == 8 - i || (o > 1)))
                console.log(" ");
            else if ((i == 3 || i == 4 || i == 5) && (o > 0))
                console.log(" ");
            else if (i == 6 && (o == 0 || (o > 1)))
                console.log(" ");
            else if (i == 7 && (o <= 1 || o == 5 || o == 6))
                console.log(" ");
            else {
                console.log(ch);
            }
        }
        console.log();
    }
}

// Function to print the letter H
function h() {
    console.log();
    for (let i = 0; i < 8; i++) {
        console.log(" ");
        for (let h = 0; h < 8; h++) {
            if (h < 2 || h > 5) {
                console.log(ch);
            }
            else if (i > 2 && i < 5) {
                console.log(ch);
            }

            else
                console.log(" ");
        }
        console.log();
    }
}

// Function to print the letter I
function i() {
    console.log();
    for (let i = 0; i < 8; i++) {

        console.log(" ");

        for (let t = 0; t < 8; t++) {

            if ((i < 1 || i > 6) && t < 8) {
                console.log(ch);
            }

            else if (i > 0 && t < 3)
                console.log(" ");
            else if (i > 0 && t > 2 && t < 5) {
                console.log(ch);
            }
            else if (i > 0 && t > 4)
                console.log(" ");
            else {
            }
        }
        console.log();
    }
}

// Function to print the letter J
function j() {
    console.log();
    for (let i = 0; i < 8; i++) {
        console.log(" ");

        for (let h = 0; h < 8; h++) {
            if (i < 1) {
                console.log(ch);
            }
            else if (i == 5 && h < 1) {
                console.log(ch);
            }
            else if (i < 7 && h > 5) {
                console.log(ch);
            }
            else if (i == 7 && (h == 0 || h == 7))
                console.log(" ");
            else if (i > 5) {
                console.log(ch);
            }
            else
                console.log(" ");
        }
        console.log();
    }
}

// Function to print the letter K
function k() {
    console.log();
    for (let i = 0; i < 8; i++) {
        console.log(" ");

        for (let k1 = 0; k1 < 7; k1++) {
            if (k1 < 2) {
                console.log(ch);
            }
            else if ((k1 >= 5 - i) && (k1 <= 6 - i)) {
                console.log(ch);
            }

            else if (i >= 4) {
                if (k1 == i - 2 || k1 == i - 1) {
                    console.log(ch);
                }
                else
                    console.log(" ");
            }
            else
                console.log(" ");
        }
        console.log();
    }
}

// Function to print the letter L
function l() {
    console.log();
    for (let i = 0; i < 8; i++) {
        console.log(" ");

        {
            console.log(ch + ch);
        }
        if (i == 6) {
            {
                console.log(ch + ch);
            }
            {
                console.log(ch + ch);
            }
            console.log(ch + ch);
        }
        if (i == 7) {
            {
                console.log(ch + ch);
            }
            {
                console.log(ch + ch);
            }
            console.log(ch + ch);
        }
        console.log();
    }
}

// Function to print the letter M
function m() {
    console.log();

    for (let i = 0; i < 8; i++) {
        console.log(" ");
        for (let j = 0; j < 8; j++) {
            if (j == 0 || j == 7) {
                console.log(ch);
            }
            else if (i < 4 && (j == 7 - i || j == i)) {
                console.log(ch);
            }
            else
                console.log(" ");
        }
        console.log();
    }
}

// Function to print the letter N
function n() {
    console.log();

    for (let i = 0; i < 8; i++) {
        console.log(" ");
        for (let n = 0; n < 8; n++) {
            if (n < 2 || n > 5) {
                console.log(ch);
            }
            else if (i == n - 1 || i == n + 1 || i == n) {
                console.log(ch);
            }
            else
                console.log(" ");
        }
        console.log();
    }
}

// Function to print the letter O
function o() {
    console.log();
    for (let i = 0; i < 8; i++) {
        console.log(" ");
        for (let o = 0; o < 8; o++) {
            if (i == 0 && (o <= 1 || o >= 6 - i))
                console.log(" ");
            else if (i == 1 && (o == 0 || o == 8 - i || (o < 6 && o > 1)))
                console.log(" ");
            else if (i == 2 && (o == 1 || o == 8 - i || (o < 6 && o > 1)))
                console.log(" ");
            else if ((i == 3 || i == 4 || i == 5) && (o > 0 && o < 7))
                console.log(" ");
            else if (i == 6 && (o == 0 || o == 8 + 5 - i || (o < 6 && o > 1)))
                console.log(" ");
            else if (i == 7 && (o <= 1 || o >= 6 - i + 7))
                console.log(" ");
            else {
                console.log(ch);
            }
        }
        console.log();
    }
}



// Function to print the letter P
function p() {
    console.log();
    for (let i = 0; i < 8; i++) {
        console.log(" ");
        {
            console.log(ch + ch);
        }

        for (let r = 0; r < 6; r++) {
            if (i === 0 && r < 5)
                console.log(ch);
            else if (i === 1)
                console.log(ch);
            else if (i < 4 && i > 0 && r > 3) {
                console.log(ch);
            }
            else if (i === 4 && r < 5) {
                console.log(ch);
            }
            else
                console.log(" ");
        }
        console.log();
    }
}

// Functions for other letters (q, r, s, t, u, v, w, x, y, z) are similar to the above, just replace the character checks and loops accordingly.

// Function to print the required pattern by taking out each character in it
function printPattern(str) {
    let inIndex = 0;

    while (str[inIndex]) {
        let ch = str[inIndex];
        if (ch.charCodeAt(0) < 95)
            ch = String.fromCharCode(ch.charCodeAt(0) + 32);

        switch (ch) {
            case 'a':
                a();
                break;
            case 'b':
                b();
                break;
            case 'c':
                c();
                break;
            case 'd':
                d();
                break;
            case 'e':
                e();
                break;
            case 'f':
                f();
                break;
            case 'g':
                g();
                break;
            case 'h':
                h();
                break;
            case 'i':
                i();
                break;
            case 'j':
                j();
                break;
            case 'k':
                k();
                break;
            case 'l':
                l();
                break;
            case 'm':
                m();
                break;
            case 'n':
                n();
                break;
            case 'o':
                o();
                break;
            case 'p':
                p();
                break;
            // Functions for other letters (q, r, s, t, u, v, w, x, y, z) are similar, just replace the function calls accordingly.
            default:
                break;
        }
        inIndex++;
    }
}

// Driver code
let ch = '*'; // Assuming '*' as the character to print the letters
let str = "GFG";
printPattern(str);

Output
   ******
  *      
 *       
 *       
 *   ****
 *   *  *
  *  *  *
   ***  *

 *******
 **     
 **     
 ****** 
 **     
 **     
 **     
        

   ******
  *      
 *       
 *       
 *   ****
 *   *  *
  *  *  *
   ***  *

Time complexity: O(1) as constant operations are done

Auxiliary Space: O(1)



Like Article
Suggest improvement
Share your thoughts in the comments