Palindrome or not in integer in C

Source code :

#include <stdio.h>

int main(){
    
    int r,sum=0,val;
    
    int num = 141; //Change the number here
 
    val=num;
    while(num){
         r=num%10;
         num=num/10;
         sum=sum*10+r;
    }
    if(val==sum)
         printf("%d is a palindrome",val);
    else
         printf("%d is not a palindrome",val);
 
    return 0;
}

Output :

141 is a palindrome

Output :


                

Comments :