I have the same code written between the IDEs, but for some reason, they have different results.
My program checks whether the given number input is a palindrome or not, say if the user input is 101 then in Dev C++ it prints out "palindrome" but in the case of using VSCode it prints out "not a palindrome". I have checked my code a lot of times and I don't see any syntax errors. I've searched for similar cases of this problem but I can't really apply or fully understand the solutions given in the post as they're using a different programming language and I'm still new to C.
int displayRev(int nNum)
{
int remainder, revNumber = 0;
while(nNum > 0)
{
remainder = nNum % 10;
nNum = nNum / 10;
revNumber = (revNumber * 10)+ remainder;
}
return revNumber;
}
int display7(int nNum)
{
int nNum1 = displayRev(nNum);
if (nNum == nNum1)
{
printf("palindrome");
}
else printf("not a palindrome");
}
int main()
{
int nNum;
printf ("Enter Number: ");
scanf ("%d", &nNum);
display7(nNum);
return 0;
}
I did check for the compiler and both IDEs are using the same compiler, the version of my GCC MinGW compiler is 6.3.0. I have tried executing the code in cmd and the output is still different from that of the Dev C++. Did I make a mistake in writing the code? or there is a different problem?