0

Division of a number by a character

Why and how? Could someone explain to me https://code.sololearn.com/cfqXZk942xMO/?ref=app

25th Jan 2020, 3:54 AM
Leo Retamar
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
25th Jan 2020, 4:14 AM
Ipang
+ 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
25th Jan 2020, 4:16 AM
HNNX 🐿
HNNX 🐿 - avatar
+ 1
Thanks guys!
25th Jan 2020, 6:11 AM
Leo Retamar