
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
Check if the value entered is palindrome or not using C language
A palindrome is nothing but any word, number, sentence, or other sequence of characters that reads the same backward as forward.
In this programming, we are trying to enter a number from console, and assign that number to temp variable.
If number is greater than zero, apply the logic given below −
while(n>0){ r=n%10; sum=(sum*10)+r; n=n/10; }
If temp=sum, then the given number is a palindrome. Otherwise, it is not a palindrome.
Example
Following is the C program for verification of a value being palindrome −
#include<stdio.h> #include<conio.h> void main(){ int n, r, sum=0, temp; printf("Enter a number: "); scanf("%d",&n); temp=n; while(n>0){ r=n%10; sum=(sum*10)+r; n=n/10; } if(temp==sum) printf("It is a palindrome number!"); else printf("It is not a palindrome number!"); getch(); }
Output
When the above program is executed, it produces the following result −
12345 It is not a palindrome number
- Related Articles
- Check whether the entered value is whitespace or not in Java
- C Program to check if an array is palindrome or not using Recursion
- Check whether the entered value is a digit or not in Java
- Check whether the entered value is a letter or not in Java
- Program to check if an Array is Palindrome or not using STL in C++
- C Program to check if an Array is Palindrome or not
- C# program to check if a string is palindrome or not
- Recursive program to check if number is palindrome or not in C++
- Write a C# program to check if a number is Palindrome or not
- Python program to check if a string is palindrome or not
- Check if number is palindrome or not in Octal in Python
- Swift Program to check if an Array is Palindrome or not
- Check if a doubly linked list of characters is palindrome or not in C++
- Queries to check if substring[L…R] is palindrome or not in C++ Program
- C# Program to Check Whether the Entered Number is an Armstrong Number or Not

Advertisements