Command Line Program to Check if a Number is Palindrome or Not

Palindrome Number Command Line Programming

It is highly advisable to go through Command Line Arguments Post before even looking at the code. Please study this for TCS and come back to this post later

#include <stdio.h>

int main(int argc, char *argv[])
{
int num, reverse_num=0,remainder,temp;
num = atol(argv[1]);
temp=num;
while(temp!=0)
{
remainder=temp%10;
reverse_num=reverse_num*10+remainder;
temp/=10;
}
if(reverse_num==num)
printf("%d is a palindrome number",num);
else
printf("%d is not a palindrome number",num);
return 0;
}

Check all other command Line Programs for TCS here on our Command line Programming Dashboard

One comment on “Command Line Program to Check if a Number is Palindrome or Not”