+ 2

Pleaze answer

int sum1 = 1000 / 5; int sum2 = sum1 / 2; int sum3 = sum1 / sum2; In the example above, the result of the division equation will be a whole number, as int is used as the data type. You can use double to retrieve a value with a decimal point. ☝️Please explain the above text to me لطفا توضیح بدید اگه فارسی هم بلدید بهتره ☝️متوجه منظورش نمیشم

23rd Jan 2019, 10:09 PM
Ruby
Ruby - avatar
2 odpowiedzi
+ 5
For first line sum1 = 1000/5; Here sum1 store the value 200. Now second line. sum2 = sum1/2; Now as sum1 contain 200 then our equation is sum2= 200/2; Here sum2 store the value 100. Now third line sum3 = 200/100; Now the sum3 store the value 2
23rd Jan 2019, 11:47 PM
AKS
AKS - avatar
0
sum1 = 1000/5 sum2 = sum1 / 2 sum3 = sum1 / sum2 puts sum3 ---------------- output : 2 --------------- mean, you do not need to int,string... You need to just variable name.That sounds unsafe, isn't it?
23rd Jan 2019, 11:43 PM
Ümit YAVUZ
Ümit YAVUZ - avatar