forked from HarshCasper/NeoAlgo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAsciiOfString.java
More file actions
36 lines (27 loc) · 738 Bytes
/
Copy pathAsciiOfString.java
File metadata and controls
36 lines (27 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
AIM :: Take a string form the user.
Consider each individual character and print the corresponding ASCII code of that character.
*/
import java.util.Scanner;
public class AsciiOfString {
public static void main(String[] args) {
//taking user input of string
System.out.print("Enter the string :: ");
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
// printing all the characters with their ASCII code
for (int i = 0; i < str.length(); i++)
System.out.println(str.charAt(i) + " = " + (int) str.charAt(i));
}
}
/*
TEST CASE
Enter the string :: ANAND
A = 65
N = 78
A = 65
N = 78
D = 68
TIME COMPLEXITY :: O(n)
SPACE COMPLEXITY :: O(1)
*/