A little help with this Arithmetic expression | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

A little help with this Arithmetic expression

find the value of the following expression and indicate what type of data should be the variable that stores the answer. A=12/3*(6+(30-15*3+(-3)/2)*1) When I type the code of the expression I know that it gives -40 but if I do it without the code it does not give me that answer. it confuses me on (-3) / 2

14th Mar 2020, 6:51 AM
vinicio a Vargas
vinicio a Vargas - avatar
1 Answer
+ 3
If we do without code we get -3/2 = -1.5 but in case of programming language we get -1 because of data type int. data type int contains value 1, 2, 3 and so on. Int doesn't alow decimal values. if we declare int value like this int a = 1.5 then compiler will give error.
14th Mar 2020, 7:01 AM
A͢J
A͢J - avatar