Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    C Program to Print Alphabets from A to Z

    C Programming Examples


    A C program to print alphabets from A to Z is a simple program that demonstrates the use of loops and character variables in C.

    Here is a simple C program that prints the alphabet from A to Z:

    Example:

    // C Program to Print Alphabets from A to Z.
    
    #include <stdio.h>
    
    void main()
    {
        char ch; // Declaring the variable
    
        for (ch = 'A'; ch <= 'Z'; ch++)
        {
            printf("%c ", ch);
        }
    }
    

    This program uses a for loop to iterate over the characters from 'A' to 'Z', inclusive. The printf statement inside the loop prints each character, followed by a space.

    The output of the program above will be:

    Program Output:

    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 
    

    Here's another way to print letters from A to Z using a loop and ASCII values.

    A C program to print alphabets from A to Z can be written using a for loop and the ASCII values of the capital letters 'A' through 'Z'.

    Example:

    #include <stdio.h>
    
    void main()
    {
      int i; // Declaring the variable
    
      for (i = 65; i <= 90; i++)
      {
        printf("%c ", i);
      }
    }
    

    The program above begins by declaring a variable i of type int. It then enters a for loop that iterates from the ASCII value of 'A' (which is 65) to the ASCII value of 'Z' (which is 90). On each iteration of the loop, the program prints the character corresponding to the ASCII value of i, followed by a space.

    When the program above is run, it will output the following:

    Program Output:

    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
    

    Conclusion

    This program is useful for learning basic programming concepts such as loops and character variables, as well as for practicing basic C syntax. It can also be a starting point for more advanced programs that involve processing and manipulating character data.



    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.