# I can't figure out why this code is not outputting properly?

/* Question:  You are required to write code that does the following:-

1. Find out the sum of the squares of the digits of the rpm
2. Multiply the number obtained in (1) by 323
3. Do a cyclic right shift of digits of the rpm i.e.
if Number is 1234, after cyclic right shift, the number will be 4123.
Thereafter, take the last two digits of the number obtained just now, and add it to the number obtained in point 2. Thus, obtaining a new rpm value.
4. Do these steps till the number of years are 10 or the harddisk has reached the maximum RPM

long long int rpm: Original value of RPM
int years: Store the number years that have elapsed
long long int finalRPM: Store the modified value of RPM i.e. the final of RPM */

void solutionRPM(long long int rpm, int &years, long long int &finalRPM) {

//Write your solution code below this line
int sqdRPM, sqdNumber_result, shiftRPM, remainRPM, numdigit, rpmDivide, rpmResult, twodigitsRPM, originalRPM, powerOne, i;
rpmDivide = rpm;
originalRPM = rpm;
remainRPM = rpm%10;
sqdRPM = rpm;
sqdNumber_result = 0;
years = 1;
while ((years<=10) && (finalRPM<=(originalRPM*8))){
while (sqdRPM != 0) {
sqdNumber_result = sqdNumber_result + (sqdRPM % 10)*(sqdRPM % 10); sqdRPM = sqdRPM/10;
} //finding sum of squares of digits of rpm
sqdNumber_result = sqdNumber_result*323; //multiply sum of squares by 323
while (rpmDivide!=0){
rpmResult = rpmDivide/10; rpmDivide = rpmResult;
numdigit++;
} //counting number of digits in rpm
for (i=0, powerOne=1; i<=(numdigit-1); i++){
powerOne = powerOne*10;
} //raising 10 to power of numdigit-1, storing in powerOne
int shiftRPM = (remainRPM)*(powerOne) + (rpm/10); //cyclic right shift of digits
twodigitsRPM = shiftRPM%(powerOne/10); //extracting last two digits
finalRPM = twodigitsRPM + sqdNumber_result; //calculating final RPM
years++;
sqdRPM = finalRPM;
rpm = finalRPM;
rpmDivide=finalRPM;
remainRPM=finalRPM%10;
numdigit=0;//substituting modified RPM for rpm in the next iteration
}
}

some error's I'm getting are:

Input rpm:8232

Your output:The harddisk is likely to crash after 1 years, with RPM of 6303968

Expected output:The harddisk is not affected with the bug. Tested for 10 Years. Final RPM is: 14882

Input rpm:7653

Your output:The harddisk is likely to crash after 1 years, with RPM of 140623784113152 Expected output:The harddisk is likely to crash after 3 years, with RPM of 68252

Output does not match