Computer Science, asked by aisha001, 4 months ago

Display the ASCII value of 2 characters taken as parameters. Also find the
difference between their ASCII values. (HINT – use type conversion - Explicit)
Sample input: A and D
Sample output: ASCII of A = 65
ASCII of D = 68
Difference in ASCII codes = - 3​

Attachments:

Answers

Answered by anindyaadhikari13
1

Question:-

Write a program to perform the following task.

Display the ASCII value of 2 characters taken as parameters. Also find the

difference between their ASCII values.

Program:-

import java.util.*;

class ASCII

{

public static void main(char a, char b)

{

int x=(int)a, y=(int)b;

System.out.println("First character: "+a);

System.out.println("Second character: "+b);

System.out.print("Difference between ASCII values is: "+(x-y));

}

}

Similar questions