Java Programming

  1. Java Program: to display ASCII value of alphabets in Java
    
        import java.util.Scanner;
    
        public class AlphabetASCIIValue {
                      
        public static void main(String[] args) {
                      
          // declare a char variable
        char ch ;
         // declare a int variable
                           int value ;
                      
         // create Scanner class object
                            // to read input
         Scanner scan = new Scanner(System.in);
                      
         // read alphabet
        System.out.print("Enter an alphabet:: ");
         ch = scan.next().charAt(0);
                      
         // convert char to ascii value
         value = ch;
                      
         // display ascii value
         System.out.println("ASCII value of "+
                         ch+" = "+value);
    
          // Or, 
          // we can directly display ASCII value
          // using type-casting (int)ch
          System.out.println("ASCII value of "+
                     ch+" = "+ (int)ch );
    
          // close Scanner class object
          scan.close();
        }
     }
    
  2. Output:
    
                    Enter an alphabet:: a
                    ASCII value of a = 97
                    ASCII value of a = 97
                  

Others Programming Language

article

programming C

Muktarul Hossain
article

C++

Muktarul Hossain
article

Python

Muktarul Hossain
article

Website Design

Muktarul Hossain