Write a C program for Palindrome number

 TASK-

Write a C program for Palindrome number.

What is a Palindrome number: Number which when reversed is equal to the original number. For example: 121, 12321, 1001 etc.



CODE:

#include<stdio.h>

int main(){

int num,reverse=0,d,original;

printf("Enter the number ");

scanf("%d",&num);

original=num; 

// saved value of num in original because as we move in loop we will lose the value of num !

while (num!=0)

{

d=num%10;

reverse=(reverse*10)+d;

num/=10;

}

if (original==reverse) // reverse is the number which we got after loop and operation on logic 

printf("\n%d is a Palindrome number",original);

else

printf("\n%d is not a Palindrome number",original);

getchar();

return 0;

}

EXPECTED OUTPUT:





NEED WORK PRODUCE WORK

My name is Abdul Rehman I am from Pakistan. I am doing BS in Computer and information sciences. Currently, I am creating these blogs to help students of computer sciences all over the world..

1 Comments

Post a Comment
Previous Post Next Post