Why this code returns a negative value? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why this code returns a negative value?

So I tried to write a Life Calculator code and this was the problem. https://code.sololearn.com/cBMsiP52MIAJ/?ref=app

18th Mar 2019, 2:09 PM
mmm...
mmm... - avatar
2 Answers
+ 6
Overflow. The value of 365*24*3600*100 is too big for the integer data type. Use long long instead
18th Mar 2019, 2:40 PM
Anna
Anna - avatar
+ 1
Thx Anna :)
19th Mar 2019, 8:53 AM
mmm...
mmm... - avatar