Program to display all alphabets from A to Z in uppercase and lowercase both - GeeksforGeeks

05 Sep, 2021
Alphabets in lowercase and uppercase can be printed using two methods, first is using ASCII values and second is to directly print values from ‘A’ to ‘Z’ using loops. Below are the implementation of both methods:
Using ASCII values:ASCII value of uppercase alphabets – 65 to 90.ASCII value of lowercase alphabets – 97 to 122.C++CJavaPython3C#PHPC++// C++ program to print alphabets#include <iostream>using namespace std;  // Function to print the alphabet// in lower casevoid lowercaseAlphabets(){    // lowercase      for (int c = 97; c <= 122; ++c)        cout << c << " ";      cout << endl;}// Function to print the alphabet// in upper casevoid uppercaseAlphabets(){      // uppercase    for (int c = 65; c <= 90; ++c)        cout << c << " ";      cout << endl;}  // Driver codeint main(){      cout << "Uppercase Alphabets" << endl;    uppercaseAlphabets(ch);      cout << "Lowercase Alphabets " << endl;    lowercaseAlphabets(ch);      return 0;}C// C program to print alphabets#include <stdio.h>  // Function to print the alphabet// in lower casevoid lowercaseAlphabets(){    // for lowercase    for (int c = 97; c <= 122; ++c)        printf("%c ", c);    printf("\n");}// Function to print the alphabet// in upper casevoid uppercaseAlphabets(){      // Run a loop from 65 to 90    for (int c = 65; c <= 90; ++c)          // print its ascii values        printf("%c ", c);      printf("\n");}  // Driver programint main(){      printf("Uppercase Alphabets\n");    uppercaseAlphabets();      printf("Lowercase Alphabets\n");    lowercaseAlphabets();      return 0;}Java// JAVA program to print alphabetclass Alpha {    private int ch;      void uppercaseAlphabets()    {          // uppercase        for (int c = 65; c <= 90; ++c)            System.out.print(" " + c);          System.out.print("\n");    }    void lowercaseAlphabets()    {          // lowercase        for (int c = 97; c <= 122; ++c)            System.out.print(" " + c);          System.out.print("\n");    }      // Driver program    public static void main(String[] args)    {        int ch;        System.out.println("Uppercase Alphabets");        Alpha ob = new Alpha();        ob.uppercaseAlphabets();          System.out.println("Lowercase Alphabets ");        ob.lowercaseAlphabets();    }}Python3# Python3 program to print alphabets  # Function to print the alphabet# in lower casedef lowercaseAlphabets():      # lowercase    for c in range(97, 123):        print(chr(c), end = " ");      print("");  # Function to print the alphabet# in upper casedef uppercaseAlphabets():      # uppercase    for c in range(65, 91):        print(chr(c), end = " ");      print("");  # Driver codeprint("Uppercase Alphabets");uppercaseAlphabets();  print("Lowercase Alphabets ");lowercaseAlphabets();  # This code is contributed by mitsC#// C# program to print alphabet  using System;class Alpha {    private int ch;      void uppercaseAlphabets()    {          // uppercase        for (int c = 65; c <= 90; ++c)            Console.Write(" " + (char)c);          Console.Write("\n");    }    void lowercaseAlphabets()    {          // lowercase        for (int c = 97; c <= 122; ++c)            Console.Write(" " + (char)c);          Console.Write("\n");    }      // Driver program    public static void Main()    {        int ch;        Console.WriteLine("Uppercase Alphabets");        Alpha ob = new Alpha();        ob.uppercaseAlphabets();          Console.WriteLine("Lowercase Alphabets ");        ob.lowercaseAlphabets();    }}PHP<?php// PHP program to print alphabets  // Function to print the alphabet// in lower casefunction lowercaseAlphabets(){    // lowercase      for ($c = 97; $c <= 122; ++$c)        echo chr($c)." ";      echo "\n";}  // Function to print the alphabet// in upper casefunction uppercaseAlphabets(){      // uppercase    for ($c = 65; $c <= 90; ++$c)        echo chr($c)." ";      echo "\n";}      // Driver code    echo "Uppercase Alphabets\n";    uppercaseAlphabets();      echo "Lowercase Alphabets \n";    lowercaseAlphabets();    // This code is contributed by mits?>Output:Uppercase Alphabets
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 
Lowercase Alphabets
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 

ASCII value of uppercase alphabets – 65 to 90.
ASCII value of lowercase alphabets – 97 to 122.
C++
C
Java
Python3
C#
PHP
// C++ program to print alphabets#include <iostream>using namespace std;  // Function to print the alphabet// in lower casevoid lowercaseAlphabets(){    // lowercase      for (int c = 97; c <= 122; ++c)        cout << c << " ";      cout << endl;}// Function to print the alphabet// in upper casevoid uppercaseAlphabets(){      // uppercase    for (int c = 65; c <= 90; ++c)        cout << c << " ";      cout << endl;}  // Driver codeint main(){      cout << "Uppercase Alphabets" << endl;    uppercaseAlphabets(ch);      cout << "Lowercase Alphabets " << endl;    lowercaseAlphabets(ch);      return 0;}
// C program to print alphabets#include <stdio.h>  // Function to print the alphabet// in lower casevoid lowercaseAlphabets(){    // for lowercase    for (int c = 97; c <= 122; ++c)        printf("%c ", c);    printf("\n");}// Function to print the alphabet// in upper casevoid uppercaseAlphabets(){      // Run a loop from 65 to 90    for (int c = 65; c <= 90; ++c)          // print its ascii values        printf("%c ", c);      printf("\n");}  // Driver programint main(){      printf("Uppercase Alphabets\n");    uppercaseAlphabets();      printf("Lowercase Alphabets\n");    lowercaseAlphabets();      return 0;}
// JAVA program to print alphabetclass Alpha {    private int ch;      void uppercaseAlphabets()    {          // uppercase        for (int c = 65; c <= 90; ++c)            System.out.print(" " + c);          System.out.print("\n");    }    void lowercaseAlphabets()    {          // lowercase        for (int c = 97; c <= 122; ++c)            System.out.print(" " + c);          System.out.print("\n");    }      // Driver program    public static void main(String[] args)    {        int ch;        System.out.println("Uppercase Alphabets");        Alpha ob = new Alpha();        ob.uppercaseAlphabets();          System.out.println("Lowercase Alphabets ");        ob.lowercaseAlphabets();    }}
# Python3 program to print alphabets  # Function to print the alphabet# in lower casedef lowercaseAlphabets():      # lowercase    for c in range(97, 123):        print(chr(c), end = " ");      print("");  # Function to print the alphabet# in upper casedef uppercaseAlphabets():      # uppercase    for c in range(65, 91):        print(chr(c), end = " ");      print("");  # Driver codeprint("Uppercase Alphabets");uppercaseAlphabets();  print("Lowercase Alphabets ");lowercaseAlphabets();  # This code is contributed by mits
// C# program to print alphabet  using System;class Alpha {    private int ch;      void uppercaseAlphabets()    {          // uppercase        for (int c = 65; c <= 90; ++c)            Console.Write(" " + (char)c);          Console.Write("\n");    }    void lowercaseAlphabets()    {          // lowercase        for (int c = 97; c <= 122; ++c)            Console.Write(" " + (char)c);          Console.Write("\n");    }      // Driver program    public static void Main()    {        int ch;        Console.WriteLine("Uppercase Alphabets");        Alpha ob = new Alpha();        ob.uppercaseAlphabets();          Console.WriteLine("Lowercase Alphabets ");        ob.lowercaseAlphabets();    }}
<?php// PHP program to print alphabets  // Function to print the alphabet// in lower casefunction lowercaseAlphabets(){    // lowercase      for ($c = 97; $c <= 122; ++$c)        echo chr($c)." ";      echo "\n";}  // Function to print the alphabet// in upper casefunction uppercaseAlphabets(){      // uppercase    for ($c = 65; $c <= 90; ++$c)        echo chr($c)." ";      echo "\n";}      // Driver code    echo "Uppercase Alphabets\n";    uppercaseAlphabets();      echo "Lowercase Alphabets \n";    lowercaseAlphabets();    // This code is contributed by mits?>
Uppercase Alphabets
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 
Lowercase Alphabets
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 

Using alphabets directly i.e.For lowercase alphabets – Run a loop from ‘a’ to ‘z’For uppercase characters – Run a loop from ‘A’ to ‘Z’C++CJavaC#PHPC++// C++ program to print alphabets#include <iostream>using namespace std;  // Function to print the alphabet// in lower casevoid lowercaseAlphabets(){    // lowercase      for (char c = 'a'; c <= 'z'; ++c)        cout << c << " ";      cout << endl;}// Function to print the alphabet// in upper casevoid uppercaseAlphabets(){      // uppercase    for (char c = 'A'; c <= 'Z'; ++c)        cout << c << " ";      cout << endl;}  // Driver codeint main(){      cout << "Uppercase Alphabets" << endl;    uppercaseAlphabets(ch);      cout << "Lowercase Alphabets " << endl;    lowercaseAlphabets(ch);      return 0;}C// C program to print alphabets#include <stdio.h>  // Function to print the alphabet// in lower casevoid lowercaseAlphabets(){    // for lowercase    for (char c = 'a'; c <= 'z'; ++c)        printf("%c ", c);    printf("\n");}// Function to print the alphabet// in upper casevoid uppercaseAlphabets(){      // Run a loop from 65 to 90    for (char c = 'A'; c <= 'Z'; ++c)          // print its ascii values        printf("%c ", c);      printf("\n");}  // Driver programint main(){      printf("Uppercase Alphabets\n");    uppercaseAlphabets();      printf("Lowercase Alphabets\n");    lowercaseAlphabets();      return 0;}Java// Java program to print alphabetclass Alpha {    private int ch;      void uppercaseAlphabets()    {          // uppercase        for (char c = 'A'; c <= 'Z'; ++c)            System.out.print(" " + c);          System.out.print("\n");    }    void lowercaseAlphabets()    {          // lowercase        for (char c = 'a'; c <= 'z'; ++c)            System.out.print(" " + c);          System.out.print("\n");    }      // Driver program    public static void main(String[] args)    {          System.out.println("Uppercase Alphabets");        Alpha ob = new Alpha();        ob.uppercaseAlphabets();          System.out.println("Lowercase Alphabets ");        ob.lowercaseAlphabets();    }}C#// C# program to print alphabetusing System;  public class Alpha {    private int ch;      // Function to print the alphabet    // in upper case    void uppercaseAlphabets()    {          // uppercase        for (char c = 'A'; c <= 'Z'; ++c)            Console.Write(" " + c);          Console.Write("\n");    }      // Function to print the alphabet    // in lower case    void lowercaseAlphabets()    {          // lowercase        for (char c = 'a'; c <= 'z'; ++c)            Console.Write(" " + c);          Console.Write("\n");    }      // Driver code    public static void Main()    {        Console.WriteLine("Uppercase Alphabets");        Alpha ob = new Alpha();        ob.uppercaseAlphabets();          Console.WriteLine("Lowercase Alphabets ");        ob.lowercaseAlphabets();    }}  // This code is contributed by Rajput-JiPHP<?php// PHP program to print alphabetfunction uppercaseAlphabets(){      // uppercase    for ($c = ord('A'); $c <= ord('Z'); ++$c)        echo(" ".chr($c));      echo("\n");}function lowercaseAlphabets(){      // lowercase    for ($c = ord('a'); $c <= ord('z'); ++$c)        echo(" ".chr($c));      echo("\n");}  // Driver programecho("Uppercase Alphabets");uppercaseAlphabets();  echo "Lowercase Alphabets ";lowercaseAlphabets();  // This code is contributed by Code_MechOutput:Uppercase Alphabets
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 
Lowercase Alphabets
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 

For lowercase alphabets – Run a loop from ‘a’ to ‘z’
For uppercase characters – Run a loop from ‘A’ to ‘Z’
C++
C
Java
C#
PHP
// C++ program to print alphabets#include <iostream>using namespace std;  // Function to print the alphabet// in lower casevoid lowercaseAlphabets(){    // lowercase      for (char c = 'a'; c <= 'z'; ++c)        cout << c << " ";      cout << endl;}// Function to print the alphabet// in upper casevoid uppercaseAlphabets(){      // uppercase    for (char c = 'A'; c <= 'Z'; ++c)        cout << c << " ";      cout << endl;}  // Driver codeint main(){      cout << "Uppercase Alphabets" << endl;    uppercaseAlphabets(ch);      cout << "Lowercase Alphabets " << endl;    lowercaseAlphabets(ch);      return 0;}
// C program to print alphabets#include <stdio.h>  // Function to print the alphabet// in lower casevoid lowercaseAlphabets(){    // for lowercase    for (char c = 'a'; c <= 'z'; ++c)        printf("%c ", c);    printf("\n");}// Function to print the alphabet// in upper casevoid uppercaseAlphabets(){      // Run a loop from 65 to 90    for (char c = 'A'; c <= 'Z'; ++c)          // print its ascii values        printf("%c ", c);      printf("\n");}  // Driver programint main(){      printf("Uppercase Alphabets\n");    uppercaseAlphabets();      printf("Lowercase Alphabets\n");    lowercaseAlphabets();      return 0;}
// Java program to print alphabetclass Alpha {    private int ch;      void uppercaseAlphabets()    {          // uppercase        for (char c = 'A'; c <= 'Z'; ++c)            System.out.print(" " + c);          System.out.print("\n");    }    void lowercaseAlphabets()    {          // lowercase        for (char c = 'a'; c <= 'z'; ++c)            System.out.print(" " + c);          System.out.print("\n");    }      // Driver program    public static void main(String[] args)    {          System.out.println("Uppercase Alphabets");        Alpha ob = new Alpha();        ob.uppercaseAlphabets();          System.out.println("Lowercase Alphabets ");        ob.lowercaseAlphabets();    }}
// C# program to print alphabetusing System;  public class Alpha {    private int ch;      // Function to print the alphabet    // in upper case    void uppercaseAlphabets()    {          // uppercase        for (char c = 'A'; c <= 'Z'; ++c)            Console.Write(" " + c);          Console.Write("\n");    }      // Function to print the alphabet    // in lower case    void lowercaseAlphabets()    {          // lowercase        for (char c = 'a'; c <= 'z'; ++c)            Console.Write(" " + c);          Console.Write("\n");    }      // Driver code    public static void Main()    {        Console.WriteLine("Uppercase Alphabets");        Alpha ob = new Alpha();        ob.uppercaseAlphabets();          Console.WriteLine("Lowercase Alphabets ");        ob.lowercaseAlphabets();    }}  // This code is contributed by Rajput-Ji
<?php// PHP program to print alphabetfunction uppercaseAlphabets(){      // uppercase    for ($c = ord('A'); $c <= ord('Z'); ++$c)        echo(" ".chr($c));      echo("\n");}function lowercaseAlphabets(){      // lowercase    for ($c = ord('a'); $c <= ord('z'); ++$c)        echo(" ".chr($c));      echo("\n");}  // Driver programecho("Uppercase Alphabets");uppercaseAlphabets();  echo "Lowercase Alphabets ";lowercaseAlphabets();  // This code is contributed by Code_Mech
Uppercase Alphabets
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 
Lowercase Alphabets
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 

These programs print all alphabets in uppercase and lowercase continuously.
ukasp
Rajput-Ji
Mithun Kumar
Code_Mech
simmytarika5
ASCII
School Programming
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Constructors in Java
Exceptions in Java
Ternary Operator in Python
Difference between Abstract Class and Interface in Java
Destructors in C++
Inline Functions in C++
Exception Handling in C++
Pure Virtual Functions and Abstract Classes in C++
Python Exception Handling
'this' pointer in C++