0
Division of a number by a character
Why and how? Could someone explain to me https://code.sololearn.com/cfqXZk942xMO/?ref=app
3 Réponses
+ 2
The character will be treated as number, the value of a character here is the ASCII code for the respective character. This happens when you mix numbers with characters in an arithmetic operation.
x = 100
'a' ASCII code is 97
x / 'a' equals to 100 / 97
+ 2
Char has an ASCII value - you can perform some arithmetic operation with them.
A = 65
B = 66
C = 67...
Java will convert this automatically:
char letterF = 65+5;
System.out.print(letterF);
Output: F
Google " ASCII table" to find all values
Also a fun exercise:
- Type out hello world with ints,
- print out the alphabet using a for loop
+ 1
Thanks guys!