Alphabets

Write a C program to print all alphabets from a to z

Write a C program to print all alphabets from a to z

In this article, we will discuss the concept of write a C program to print all alphabets from a to z

In this post, we are going to learn how to write a program to  print all characters of English alphabet  using  for, while and do-while  loop in C language

Code to print all characters of alphabets

Code to print all characters of alphabet using for loop

In this code, we are going to learn how to print all characters of alphabet using for loop in C language

Program 1

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

int main()
{
    char ch;
    //declare a char type variable

    printf("The list of Alphabets from A to Z\n");
    for(ch='A'; ch<='Z'; ch++){
        printf("%c ",ch);
    }

    printf("\n\nThe list of Alphabets from a to z\n");
    for(ch='a'; ch<='z'; ch++){
        printf("%c ",ch);
    }
    getch();
    return 0;
}

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

The list of Alphabets from A to Z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

The list of Alphabets from a to z
a b c d f g h i j k l m n o p q r s t u v w x y z


Code to print all characters of alphabet using while loop

In this code, we are going to learn how to print all characters of English alphabet using while loop in Java language

Program 2

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

int main()
{
    char ch;
    //declare a char type variable

    printf("The list of Alphabets from A to Z\n");
    ch='A';
    while( ch<='Z'){
        printf("%c ",ch);
        ch++;
    }

    printf("\n\nThe list of Alphabets from a to z\n");
    ch='a';
    while( ch<='z'){
        printf("%c ",ch);
        ch++;
    }
    getch();
    return 0;
}

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

The list of Alphabets from A to Z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

The list of Alphabets from a to z
a b c d f g h i j k l m n o p q r s t u v w x y z

 

 

Code to print all characters of alphabet using do-while loop

In this code, we are going to learn how to print all characters of alphabet using do-while loop in C language

Program 3

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

int main()
{
    char ch;
    //declare a char type variable

    printf("The list of Alphabets from A to Z\n");
    ch='A';
    do{
        printf("%c ",ch);
        ch++;
    }while( ch<='Z');

    printf("\n\nThe list of Alphabets from a to z\n");
    ch='a';
    do{
        printf("%c ",ch);
        ch++;
    }while( ch<='z');
    getch();
    return 0;
}

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

The list of Alphabets from A to Z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

The list of Alphabets from a to z
a b c d f g h i j k l m n o p q r s t u v w x y z

 

 

Suggested for you

For loop in C language

while loop in c language

do-while loop in c language

Operator in C language

 

Similar post

 

Similar post

Java program to print all alphabets in given range

C program to print all alphabets in given range

C++ program to print all alphabets in given range

 

Java program to print all alphabets using loops

C program to print all alphabets using loops

C++ program to print all alphabets using loops

 

Karmehavannan

Recent Posts

Multiply two numbers in Java using scanner| 5 different ways

Multiply two numbers in Java using scanner| 5 different ways In this article, we will…

3 months ago

5 different ways to Divide two numbers in Java using scanner

5 Different ways to Divide two numbers in Java using scanner In this article, we…

3 months ago

Learn 8 Ways to Subtract Two Numbers Using Methods in Java

Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…

4 months ago

10 ways to subtract two numbers in Java

10 ways to subtract two numbers in Java In this article, we will discuss the…

4 months ago

Java Code Examples – Multiply Two Numbers in 5 Easy Ways

Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…

4 months ago

How to Divide two numbers in Java| 5 different ways

How to Divide two numbers in Java| 5 different ways In this article, we will…

4 months ago

This website uses cookies.