211k views
4 votes
For the double variables x and y, if x = 2.5 and y = 4.0, what is the value of z after this statement is executed? int z = (int) x (int) y;

User Skybunk
by
7.3k points

1 Answer

1 vote

Answer:

1 - it depend on programming language you are working with if it is in java it will show an error.

2 - by using force change you get value which is int z=0

when any float ot double is converted in int. it depend on decimals.

for e.g. if the number is 2.4 it will be treated as 2 in int.

if the number is 2.6 it will be treated as 3 in int

User Louis Lecocq
by
6.4k points