+ 3
C# - A strange assignment
Why on Earth in this code is y assigned 6? In effect, result is 60. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static int Multi(int a, int b, int c){ return (a * b * c); } static void Main(string[] args) { int x,y,z; x = 5; y = x++; //so, y is assigned 6? z = x/3; Console.Write(Multi(x,y,z)); } } }
5 ответов
+ 1
x = 6
y = 5
z = x/3 = 6/3 = 2
6 * 5 = 30
30 * 2 = 60
Why should it be 50
+ 3
I agree with you but so, Multi should return 50. Instead, it returns 60!
+ 3
I confused, sorry ☺️
0
in addtion to ~ swim ~
Y is 5
X is 6
https://code.sololearn.com/c6uy4RskK38L