Print AscII Value of given input String.
Print AscII Value of given input String.
Description:-
Here we will be solving an problem where once user gives string input we need to give output as a Ascii value of each character in that string.
Code:-
import java.lang.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
int len = str.length();
char[] charArray = str.toCharArray();
int asciValue=0;
for(int i=0;i<len;i++){
asciValue = charArray[i];
System.out.print(asciValue+" ");
}
}
}
Feedback:-
After reading this page if you have any feedback do let me know in comments; i will try to bring those things in my upcoming posts.
Comments
Post a Comment