Multiple choice technology programming languages

what is output of print abs("123abc") ?

  1. 0

  2. 123

  3. abc

  4. 12

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The abs() function returns the absolute value of a number. When given '123abc', Perl converts it to numeric context which takes 123 (stopping at non-numeric 'abc'), then returns abs(123) = 123. It doesn't return 0 or ignore the numeric part. This demonstrates Perl's automatic number-to-string conversion.