0

Let's consider the scenario. I declared

int n;
long int sum;

and consider expression sum = (n*(n-1))/2;

Is n converted to long int and then the multiplication is done, or does the multiplication happen first and then the truncated value (if it exceeds int) is converted to long int and stored in sum?

melpomene
  • 84,125
  • 8
  • 85
  • 148

0 Answers0