What will z equal? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What will z equal?

int x=5; int y=4; int z= x/y;

12th Sep 2021, 2:37 PM
Dapo Adedire😎
Dapo Adedire😎 - avatar
5 Answers
+ 2
mesarthim 5 divided by 4 is 1 (with reminder 1) C++ does not convert the numbers to floats and perform the real division (like it does not do that for addition, subtraction and multiplication), it directly performs the Euclidean division (like it directly performs the integer addition, subtraction and multiplication)
12th Sep 2021, 6:36 PM
Angelo
Angelo - avatar
+ 3
It's 1 because you are taking value in integer
12th Sep 2021, 3:15 PM
Deepika Singh
Deepika Singh - avatar
+ 2
𝕥𝕖𝕤𝕝𝕒✨ z will be 1 because x and y are int
12th Sep 2021, 2:41 PM
A͢J
A͢J - avatar
+ 1
[EDITED] You defined variable z as integer so it must be 1. Happy coding!
12th Sep 2021, 3:45 PM
mesarthim
mesarthim - avatar
+ 1
Oh, that's right Angelo. Thanks for explanation, I must be careful more.
12th Sep 2021, 8:00 PM
mesarthim
mesarthim - avatar