In the previous blog we found the remainder of the number .Now we will  find the ASCII value of the character .

What is ASCII  Table ?

The American Standard Code for Information Interchange (ASCII) is a character encoding standard for text files stored on computers and other devices. ASCII is a character set made up of 128 symbols that is a subset of Unicode. Letters (both capital and lowercase), numerals, punctuation marks, special characters, and control characters are among the symbols. Each symbol in the character set has an equivalent Hexadecimal and Octal value, as well as a Decimal value spanning from 0 to 127.

(Credits:-This image is taken from https://commons.m.wikimedia.org/wiki/File:ASCII-Table-wide.svg)

To find the ASCII value of a character
import java.io.*;
import java.util.*;
public class ascii{
    public static void main (String [] args)
    {
        char character;
        System.out.println("Enter the character: ");
        Scanner sc =new Scanner(System.in);
        character=sc.next().charAt(0);
        int value;
        value=character;
        System.out.print("ASCII value of the character is "+value);
    }
}

Algorithm:

1.Start 

2.Use  a char datatype and declare the variable as character.

3.In the print statement display a text "Enter the character".

4.Use the scanner class to get the input of the character .We will 

5.Now to print the ASCII value of the character since the ASCII value are all of integer datatype we use the format specifier "%d" to print the value of the character 

6.Stop 

Screenshot :-

1.Code Screenshot:-

2.Output Screenshot:-


In the next blog we will see how to swap two numbers .