Program to Print Alphabets from A to Z Using Loop - GeeksforGeeks

16 Jun, 2021
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++14
C
Java
Python3
C#
Javascript
// C++ program to find the print// Alphabets from A to Z#include <bits/stdc++.h>using namespace std; int main(){    // Declare the variables    char i;     // Display the alphabets    cout << "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        cout << i <<" ";    }     return 0;} // This code is contributed by// Shubhamsingh10
// 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;}
// Java program to find the print// Alphabets from A to Zclass 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 */
# Python3 program to find the print# Alphabets from A to Z if __name__ == '__main__':         # Declare the variables    i = chr;     # Display the alphabets    print("The Alphabets from A to Z are: ");     # Traverse each character    # with the help of for loop    for i in range(ord('A'), ord('Z') + 1):         # Print the alphabet        print(chr(i), end=" ");         # This code is contributed by Rajput-Ji
// C# program to find the print// Alphabets from A to Zusing System; class GFG{     public static void Main(String[] args)    {        // Declare the variables        char i;         // Display the alphabets        Console.Write("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            Console.Write("{0} ", i);        }     }} // This code is contributed by Rajput-Ji
<script> // Javascript program to find the print// Alphabets from A to Z // Declare the variableslet i; // Display the alphabetsdocument.write("The Alphabets from A" +               " to Z are: " + "</br>"); // Traverse each character// with the help of for loopfor(i = 'A'.charCodeAt();    i <= 'Z'.charCodeAt(); i++){         // Print the alphabet    document.write(        String.fromCharCode(i)  + " ");} // This code is contributed by decode2207 </script>
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 
 
princiraj1992
Rajput-Ji
SHUBHAMSINGH10
Code_Mech
decode2207
school-programming
C Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C Program to read contents of Whole File
Header files in C/C++ and its uses
How to return multiple values from a function in C or C++?
How to Append a Character to a String in C
Program to print ASCII Value of a character
C program to sort an array in ascending order
time() function in C
Flex (Fast Lexical Analyzer Generator )
C Program to Swap two Numbers
Producer Consumer Problem in C