Program to Print Alphabets from A to Z Using Loop

The task is to print the alphabets from A to Z using a loop.



In the below program, for loop is used to print the alphabets from A to Z. A loop variable is taken to do this of type ‘char’. The loop variable ‘i’ is initialized with the first alphabet ‘A’ and incremented by 1 on every iteration. In the loop, this character ‘i’ is printed as the alphabet.

Program:

C

filter_none

edit
close

play_arrow

link
brightness_4
code

// C program to find the print
// Alphabets from A to Z
  
#include <stdio.h>
  
int main()
{
    // Declare the variables
    char i;
  
    // Display the alphabets
    printf("The Alphabets from A to Z are: \n");
  
    // Traverse each character
    // with the help of for loop
    for (i = 'A'; i <= 'Z'; i++) {
  
        // Print the alphabet
        printf("%c ", i);
    }
  
    return 0;
}

chevron_right


Java

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java program to find the print
// Alphabets from A to Z
class GFG
{
  
    public static void main(String[] args) 
    {
        // Declare the variables
        char i;
  
        // Display the alphabets
        System.out.printf("The Alphabets from A to Z are: \n");
  
        // Traverse each character
        // with the help of for loop
        for (i = 'A'; i <= 'Z'; i++)
        {
  
            // Print the alphabet
            System.out.printf("%c ", i);
        }
  
    }
}
  
/* This code contributed by PrinciRaj1992 */

chevron_right


Output:

The Alphabets from A to Z are: 
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 


My Personal Notes arrow_drop_up

Technical Content Engineer

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : princiraj1992



Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.