C program to check whether a given number is a palindrome or not

This program I provided checks whether a given number is a palindrome or not. A palindrome number is a number that remains the same when its digits are reversed. For example, 121 is a palindrome because it remains the same when its digits are reversed.

The program first prompts the user to enter a number, then stores it in the `originalNum` variable. It then reverses the number using a while loop and stores the reversed number in the `reversedNum` variable.

If the reversed number is equal to the original number, the program outputs that the number is a palindrome, otherwise, it outputs that the number is not a palindrome.

• the program first declares several integer variables – num, reversedNum, remainder, and originalNum.
• It prompts the user to enter an integer using the `printf` and `scanf` functions.
• The program then stores the entered integer in the `originalNum` variable.
• The program then reverses the entered integer using a `while` loop. This is done by continuously taking the remainder of the entered integer when divided by 10 and adding it to the `reversedNum` variable, which is initially set to 0. The `num` variable is then divided by 10 in each iteration to remove the last digit.
• If the reversed number is equal to the original number, the program outputs that the number is a palindrome. Otherwise, it outputs that the number is not a palindrome.
``````#include <stdio.h>

int main() {
int num, reversedNum = 0, remainder, originalNum;

printf("Enter an integer: ");
scanf("%d", &num);

originalNum = num;

// reverse the integer
while (num != 0) {
remainder = num % 10;
reversedNum = reversedNum * 10 + remainder;
num /= 10;
}

if (originalNum == reversedNum)
printf("%d is a palindrome.", originalNum);
else
printf("%d is not a palindrome.", originalNum);

return 0;
}``````

Digital Marketing Consultants and Social Media Marketing Expert with over 3 years of rich experience in various Branding, Promotions, business directories, On pages and off page optimization, Link building Advertising, Research, paid advertisement, content writing and marketing