+ 1

C++ - An assignment not assigned

Let's consider the following code: int x = 10, s = 0; s = sizeof(x = x + 20); cout << x; Result is always 10, irrespective what number you use instead of 20. Is like assignment internal to sizeof() is not performed. Why so?

21st Aug 2019, 5:28 PM
Paolo De Nictolis
Paolo De Nictolis - avatar
1 Respuesta
+ 11
Paolo De Nictolis sizeof () operator is return the size of the data types, as you have declare integers value which size is 4 so answer always become 4 which is default size of integer. On printing the value of x always 10 will be coming as their is no operation performing outside the size of operator and inside the size of will return only the size of data type
21st Aug 2019, 5:47 PM
GAWEN STEASY
GAWEN STEASY - avatar