Below code returns 7523503 instead of 7523505 in VS studio code. I ran it in an online IDE and it returns 7523505 as it's supposed to do. I've got g++ version 9.2.0 installed. How can I fix this?
#include <iostream>
#include <cmath>
using namespace std;
void inserare(int &n)
{
int c = 0;
int sol = 0;
int uc1 = n%10;
while(n!=0)
{
n /= 10; int uc2= n%10;
if(uc2 != 0 && n % 10000 != 0)
{
sol += uc1 * pow(10,c++);
int dif = uc1 - uc2;
if(dif<0) dif *= -1;
sol += dif * pow(10, c++);
}
else sol += uc1 * pow(10, c++);
uc1 = uc2;
}
n = sol;
}
int main()
{
int n = 7255;
inserare(n);
cout << n;
return 0;
}