One plus one

12.08.2019

A little funny quiz I've came up with. Guess programming language:

  1. '1' + 1 = 11
  2. '1' + 1 = 2
  3. '1' + 1 = 50
  4. '1' + 1 = TypeError

Answers below

  1. Javascript. Press F12 in your browser (open dev tools console) and try for yourself
> '1' + 1
< "11"
  1. PHP
echo '1' + 1;
2
  1. C. '1' has char type, which is also an ASCII code of the symbol '1', which is 49. Plus one makes it 50.
printf("%d", '1' + 1);
50
  1. Python.
print '1' + 1;
TypeError: cannot concatenate 'str' and 'int' objects