+ 6

Two identical codes with different outputs

Hello Why aren't outputs the same? https://code.sololearn.com/cz0145bf6vSr/?ref=app https://code.sololearn.com/w6o50b5dOsxR/?ref=app

18th Dec 2021, 5:55 PM
hosein Zarei
3 Réponses
+ 4
hosein Zarei PHP is different than others language. Here increment happens from right side means ++a first will be increment which will be 2 then $a += 2 now $a is 2 so $a = 2 + 2 = 4 in C# a += ++a; a = 1 + 2 = 3 https://code.sololearn.com/w07HrjxKNOct/?ref=app
18th Dec 2021, 6:06 PM
A͢J
A͢J - avatar
+ 2
Languages has their own implementation in which operation will be done first. In a first glance it seems is the same code, but it is not.
18th Dec 2021, 6:13 PM
Anya
Anya - avatar
+ 1
The fundamentals for both languages are the same but the implications are different
20th Dec 2021, 9:30 AM
Mohammed Alimam
Mohammed Alimam - avatar