In this article, we will discuss the concept of Program for Display Alphabets in Java using ASCII value
In this post, we are going to learn how to display all the upper case(A to Z) and lower case (a to z) Alphabets using ASCII value in Java programming language
ASCII value of upper case Alphabets letters are between 65 – 90
ASCII value of lower case Alphabets letters are between 97 – 122
The program displays all the upper case and lower case alphabet letters between a to z using for loop in Java language
Program 1
public class DisplayAlphabetsfor{ public static void main(String args[]){ char ch;//char variable declaration //Printing lower case Alphabets System.out.println("Lower case Alphabets are: \n"); for(ch=97; ch<=122; ch++){//using ASCII value for lower case Alphabets System.out.print(ch+" "); //display Lower case Alphabets with space } System.out.print("\n");//move to next line //Printing upper case Alphabets System.out.println("Upper case Alphabets are: \n"); for(ch=65; ch<=90; ch++){//using ASCII value for upper case Alphabets System.out.print(ch+" "); //display Upper case Alphabets with space } } }
When the above code is executed, it produces the following result
In the above program, we are using two for loops, one is used to print upper case letters and another to print lower case letters
Approach
The program displays all the upper case and lower case alphabet letters between a to z using while loop in Java language
Program 2
public class DisplayAlphabetswhile{ public static void main(String args[]){ char ch;//char variable declaration //Printing lower case Alphabets System.out.println("Lower case Alphabets are: \n"); ch=97; while(ch<=122){//using ASCII value for lower case Alphabets System.out.print(ch+" "); //display lower case Alphabets with space ch++; } System.out.print("\n");//move to next line //Printing upper case Alphabets System.out.println("Upper case Alphabets are: \n"); ch=65; while(ch<=90){//using ASCII value for upper case Alphabets System.out.print(ch+" "); //display upper case Alphabets with space ch++; } } }
When the above code is executed, it produces the following result
In the above program, we are using two while loops, one is used to print upper case letters and another to print lower case letters
Approach
The program displays all the upper case and lower case alphabet letters between using the do-while loop in Java language
Program 3
public class DisplayAlphabetsdowhile{ public static void main(String args[]){ char ch;//char variable declaration //Printing lower case Alphabets System.out.println("Lower case Alphabets are: \n"); ch=97; do{//using ASCII value for lower case Alphabets System.out.print(ch+" "); //display lower case Alphabets with space ch++; }while(ch<=122); System.out.print("\n");//move to next line //Printing upper case Alphabets System.out.println("Uppercase Alphabets are: \n"); ch=65; do{//using ASCII value for upper case Alphabets System.out.print(ch+" "); //display upper case Alphabets with space ch++; }while(ch<=90); } }
When the above code is executed, it produces the following result
In the above program, we are using two do-while loops, one is used to print upper case letters and another to print lower case letters
Approach
Suggested for you
do-while loop in Java language
Similar post
Java program to print all upper case and lower case Alphabets
C++ program to print all upper case and lower case Alphabets
C program to print all upper case and lower case Alphabets
C Program for Display Alphabets in Java using ASCII value
Java Program for Display Alphabets in Java using ASCII value
C++ Program for Display Alphabets in Java using ASCII value
Python Program for Display Alphabets in Java using ASCII value
PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…
PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…
5 methods to add two numbers in Java In this tutorial, we will discuss the…
Python full Pyramid star pattern program In this tutorial, we will discuss the concept of…
Write a function or method to convert C into F -Entered by the user In…
How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…