I am doing a code and in that there is a line where a,b,c,d are integers,
int a ,b ,c ,d;
long long sum =a + b +c+ d;
I got overflow as error
After i executed code i h=got overflow but after referring answer the sum need to be written as
long long sum=a;
sum+=b;
sum+=c;
sum+=d;
For this line i got correct result .But why I am unable to understand the difference?
New contributor
Minion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.