I am trying to find the square of a int
. My code looks like below:
long long sqr=0;
int num=77778;
sqr= num*num;
The result should have been 6049417284
But when I check the output it shows 1754449988
.
What is the mistake I am doing?
long long
should be able to store the result but why am I getting a different value?
num*num
gives an integer (and overflows), which is then implicitly casted to long long. – Braggadocio