How does comparison operators work over strings? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How does comparison operators work over strings?

14th Feb 2017, 3:23 PM
Dinesh
Dinesh - avatar
4 Answers
+ 2
I suppose the two strings have to be exactly same, the same size and the same characters at the same index
14th Feb 2017, 4:32 PM
‎ɐısıօլɐ
‎ɐısıօլɐ - avatar
+ 2
In short - they compare the chars in the strings by alphabetical (for letters) or ASCII table order.
14th Feb 2017, 6:32 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
The comparison operator "==" compares the characters, their ASCII value as well and word length So if you have three strings lets say; a = "DIVYA" b = "divya" c = "Divya" All these three on comparison produces the result "Not same". Because here the length of the word is same, word itself is same. But their ASCII values are different
27th Feb 2017, 11:13 AM
Akhil Haridasan
Akhil Haridasan - avatar
0
Hi
14th Feb 2017, 3:25 PM
Luke Hegelund
Luke Hegelund - avatar