What's wrong with my code. Gives unexpected result Please help!


#1

string Solution::convertToTitle(int A) {
int rem = 0;
rem = A%26;
int i = 0;
string result="";
while(A>0)
{
if(rem == 0)
{
result += ‘Z’;
A = (A/26) -1;
}
else
{
result += char(rem + 64);
A = A/26;
}
}
result += ‘\0’;
return result;
}