+ 7
String output
Please explain why the first two numers add up, but the last two don't? https://code.sololearn.com/cZ973t5fmqy0/?ref=app
11 odpowiedzi
+ 7
Because after the first two numbers, there is a string and everything is evaluated as string and every number after the quotes is concatenated.
+ 5
int: 1+1 = 2
String: 2+"1+1" = "21+1"
String: "21+1"+1 = "21+11"
String: "21+11"+1 = "21+111"
+ 4
No, but the program didn't recognize the assignment as string until you wrote +"" then it started behaving like a string the same as if you will use the () as I hava already said the behavior will be like int because it doesn't care about the part outside
+ 2
That is, despite the fact that this is String, the first two numbers are perceived as int?
+ 2
Thanks everyone!
+ 2
Because the "+" operator in the quoted string acts as a string delimiter operator :-) (two strings are concatenated)
+ 1
In addition to TheWh¡teCat you can add () on the last two digits and see that they will evaluate to 2
0
2+1+2=21+2
0
Easy
0
Print("halo world")
0
Hello lryna