BM Balmiki Mandal 17 Sep 2023 10 views 0 comments C Programming

Alphabet Pattern (A-Z) in c programming

Alphabet Pattern Printing in C: A-Z with Examples

Creating alphabet patterns in C for all the letters of the alphabet would involve writing specific code for each letter. Below, I'll provide a list of patterns for a few letters ('A', 'B', 'C', 'D', and 'E') to give you an idea. You can follow a similar approach for other letters.

Pattern for 'A':

#include <stdio.h>

int main() {
    int i, j, n;
    printf("Enter the number of rows (odd): ");
    scanf("%d", &n);

    // Upper part of the 'A'
    for(i = 0; i < n/2 + 1; i++) {
        for(j = 0; j < (2*n); j++) {
            if(j >= n-i && j <= n+i)
                printf("*");
            else
                printf(" ");
        }
        printf("\n");
    }

    // Lower part of the 'A'
    for(i = 0; i < n/2; i++) {
        for(j = 0; j < (2*n); j++) {
            if(j == n || j == (2*n)-1-n || (i == n/2-1 && j > n && j < (2*n)-1-n))
                printf("*");
            else
                printf(" ");
        }
        printf("\n");
    }

    return 0;
}

Pattern for 'B':

#include <stdio.h>

int main() {
    int i, j, n;
    printf("Enter the number of rows: ");
    scanf("%d", &n);

    // Upper part of the 'B'
    for(i = 0; i < n; i++) {
        printf("*");
        for(j = 0; j < n; j++) {
            if((i == 0 || i == n/2 || i == n-1) && j < n-1)
                printf("*");
            else if(j == n-1 && !(i == 0 || i == n/2 || i == n-1))
                printf("*");
            else
                printf(" ");
        }
        printf("\n");
    }

    return 0;
}

Pattern for 'C':

#include <stdio.h>

int main() {
    int i, j, n;
    printf("Enter the number of rows: ");
    scanf("%d", &n);

    for(i = 0; i < n; i++) {
        printf("*");
        for(j = 0; j < n-1; j++) {
            if((i == 0 || i == n-1) && j < n-2)
                printf("*");
            else if(i > 0 && i < n-1 && j == 0)
                printf("*");
            else
                printf(" ");
        }
        printf("\n");
    }

    return 0;
}

Pattern for 'D':

 
#include <stdio.h>

int main() {
    int i, j, n;
    printf("Enter the number of rows: ");
    scanf("%d", &n);

    for(i = 0; i < n; i++) {
        printf("*");
        for(j = 0; j < n-1; j++) {
            if(j == n-2 && !(i == 0 || i == n-1) || (i == 0 || i == n-1) && j < n-2)
                printf("*");
            else
                printf(" ");
        }
        printf("\n");
    }

    return 0;
}
 

Pattern for 'E':

#include <stdio.h>

int main() {
    int i, j, n;
    printf("Enter the number of rows: ");
    scanf("%d", &n);

    for(i = 0; i < n; i++) {
        printf("*");
        for(j = 0; j < n-1; j++) {
            if((i == 0 || i == n/2 || i == n-1) && j < n-2)
                printf("*");
            else
                printf(" ");
        }
        printf("\n");
    }

    return 0;
}

These are just a few examples. You can use similar logic to create patterns for other letters. Remember to adjust the loop conditions and positions of stars based on the desired shape of each letter.

0 Comments

No comments yet, Be the first to comment.

Post a Comment

Please sign in to post a comment.

Related Posts

Bit wise operators Assignment

Bitwise Operators practical assignment: Take runtime input, bit-level manipulation, and different data units r...

AG Anvesh G 27 Sep 2026
Understanding Float and Double Binary Representation in C

Understanding Float and Double Binary Representation in CIntroduction:When we store decimal numbers such as 10...

AG Anvesh G 31 May 2026
Topic-wise C Programming Interview Questions

C Programming Interview Questions – Topic Wise1. IntroductionC programming is one of the most important langu...

AG Anvesh G 30 May 2026