Alphabet Pattern

C code to Alphabet triangle pattern using do-while loop

C code to Alphabet triangle pattern using the do-while loop

In this article, we will discuss the concept of C code to Alphabet triangle pattern using the do-while loop in C programming language

We can print various type of number, asterisk, binary patterns using for, while and do-while loop in C language

In this post, we will discuss how to write a program to print different alphabet triangle pattern using the do-while loop in C language.

 

To understand this example programs, you should have previous knowledge of following Java topics

Do while loop in C language

Nested do while loop in C language

C code to Alphabet triangle pattern

Program to Alphabet triangle pattern 1

Program 1

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int rows;
    printf("Alphabet pattern\n");
    printf("Enter the number of rows\n");
    //Takes input from the user to number of rows
    scanf("%d",&rows);
    printf("\n");
    int i,j;
    i=1;
    do{//outer loop
             j=1;
            do{//inner loop
                 printf("%c",'A'-1+i);
                 j++;
    }while(j<=i);
    printf("\n");
    i++;
    }while(i<=rows);
    getch();
    return 0;
    }

 

When the above code is executed, it produces the following results

Alphabet pattern 1

 

 

Program to Alphabet triangle pattern 2

Program 2

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j,rows;
    printf("Enter the number of rows: ");
//Takes input from the user to number of rows
    scanf("%d",&rows);
    printf("\n");
    i=rows;
    do{//outer loop
            j=i;
        do
{//inner loop

    printf("%c",'A'-1+j);
    j--;
}while(j>=1);
i--;
printf("\n");
}while(i>=1);
    getch();
    return 0;
}

When the above code is executed, it produces the following results

Alphabet pattern 2

 

Program to Alphabet triangle pattern 3

Program 3

#include <stdio.h>
#include <stdlib.h>

int main()
{
     int i,j,rows;
    printf("Alphabet pattern\n\n");
     printf("Enter the number of rows\n");
//Takes input from the user to number of rows
     scanf("%d",&rows);
i=1;
    do{
            j=rows;
        do{
        printf("%c",'A'-1+i);
     j--;
    }while(j>=i);
    printf("\n");
     i++;
    }while(i<=rows);
     getch();
    return 0;
}

When the above code is executed, it produces the following results

Alphabet pattern 3

 

Program to Alphabet triangle pattern 4

Program 4

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j,rows;
    printf("Alphabet pattern \n\n");
    printf("Enter number of rows\n");
//Takes input from the user to number of rows
    scanf("%d",&rows);
    printf("\n");
i=1;
   do{
        j=1;
        do{
        printf("%c",'A'+j-1);
   j++;
    }while(j<=i);
    printf("\n");
     i++;
    }while(i<=rows);
     getch();
    return 0;
}

When the above code is executed, it produces the following results

Alphabet pattern 4

 

Program to Alphabet triangle pattern 5

Program 5

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j,rows;
    printf("Alphabet pattern 1\n\n");
    printf("Enter the number of rows\n\n");
//Takes input from the user to number of rows
    scanf("%d",&rows);
    printf("\n");
    i=rows;
    do{
            j=i;
        do{
        printf("%c",'A'+j-1);
    j++;
    }while( j<=rows);
    printf("\n");
    i--;
    }while( i>=1);
     getch();
    return 0;
}

 

When the above code is executed, it produces the following results

Alphabet pattern 5

Program to Alphabet triangle pattern 6

Program 6

#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("Alphabet pattern \n\n");
    printf("Enter the number of rows \n\n");
//Takes input from the user for number of rows
    int i,j,rows;
    scanf("%d",&rows);
    i=rows;
    do{
            j=1;
        do{
        printf("%c",'A'+j-1);
    j++;
    }while( j<=i);
    printf("\n");
    i--;
    }while( i>=1);
     getch();
    return 0;
}

When the above code is executed, it produces the following results

 

Program to Alphabet triangle pattern 7

Program 7

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j,rows;
    printf("Enter the number of rows\n");
//Takes input from the user for number of rows
    scanf("%d",&rows);
    printf("your pattern here\n");
    i=1;
    do{
            j=i;
        do{
            printf("%c",(char)(j+64));
            j++;
        }while(j<=rows);
        i++;
        printf("\n");
    }while(i<=rows);
    getch();
    return 0;
}

When the above code is executed, it produces the following results

Alphabet pattern 7

 

Program to Alphabet triangle pattern 8

Program 8

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j,rows;
    char ch='A';
    printf("Enter the number of rows: \n");
//Takes input from the user for number of rows
    scanf("%d",&rows);
    i=1;
    do{
            j=1;
        do{
        printf("%c ",ch++);
     j++;
    }while(j<=i);
    printf("\n");
    i++;
    }while(i<=rows);
    getch();
    return 0;
}

When the above code is executed, it produces the following results

Alphabet pattern 8

Program to Alphabet triangle pattern 9

Program  9

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j,rows,num,count;
    printf("Enter the number of rows: \n");
//Takes input from the user for number of rows
    scanf("%d",&rows);
    i=1;
    while(i<=rows){
            num=rows-1;
    count=i;
j=1;
       do{
        printf("%2c",(char)(count+64));
        count=count+num;
        num--;
         j++;
    } while( j<=i);
    printf("\n");
     i++;
    }
    getch();
    return 0;
}

When the above code is executed, it produces the following results

Alphabet pattern 9

Program to Alphabet triangle pattern 10

Program 10

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j,k,rows;

    printf("Enter the number of rows\n");
//Takes input from the user for number of rows
    scanf("%d",&rows);
    i=rows;
    do{
        k=i;
        j=1;
        do{
            printf("%c",(char)(k+64));
j++;
k++;
        }while(j<=i);
        printf("\n");
i--;
    }while(i>=1);
    getch();
    return 0;
}

When the above code is executed, it produces the following results

 

Program to Alphabet triangle pattern 11

Program 11

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j,k,rows;

    printf("Enter the number of rows\n");
//Takes input from the user for number of rows
    scanf("%d",&rows);
    i=1;
    do{
        j=1;
        do{
                printf(" ");

j++;
        }while(j<=rows-i+1);
        k=1;
       do{

            printf("%c",(char)(k+64));
k++;
        } while(k<=i);
        printf("\n");
i++;
    }while(i<=rows);
    getch();
    return 0;
}


When the above code is executed, it produces the following results

 

Program to Alphabet triangle pattern 12

Program 12

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j,k,rows;

    printf("Enter the number of rows\n");
//Takes input from the user for number of rows
    scanf("%d",&rows);
    i=1;
   do{
        j=1;
        do{
                printf(" ");

j++;
        }while(j<=rows-i);
        k=1;
        do{

            printf("%c",(char)(j+64));
k++;
        }while(k<=i);
        printf("\n");
i++;
    } while(i<=rows);
    getch();
    return 0;
}

When the above code is executed, it produces the following results

 

Suggested for you

Data type in C language

Variable in C language

The operator in C language

 

Similar post

C code to Alphabet triangle pattern using the do-while loop

C++ code to Alphabet triangle pattern using the do-while loop

Java code to Alphabet triangle pattern using the do-while loop

Alphabet triangle pattern in C language

Alphabet triangle pattern in C language using while loop

Alphabet triangle pattern in Java language

Alphabet triangle pattern in Java language using while loop

Alphabet triangle pattern in C++ language

Alphabet triangle pattern in C++ language using while loop

 

C++ program to Integrated triangle patterns using for loop
Alphabet triangle pattern using do-while loop in Java
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

PHP Star Triangle pattern program

PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…

1 month ago

PHP Full Pyramid pattern program

PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…

2 months ago

5 methods to add two numbers in Java

5 methods to add two numbers in Java In this tutorial, we will discuss the…

2 months ago

Python Full Pyramid star pattern program

Python full Pyramid star pattern program In this tutorial, we will discuss  the concept of…

5 months ago

Write a function or method to convert C into F -Entered by user

Write a function or method to convert C into F -Entered by the user In…

10 months ago

How to write a function or method to convert Celsius into Fahrenheit

How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…

10 months ago