What will z equal? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
+ 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