0% found this document useful (0 votes)
51 views4 pages

C Program To Check Whether A Number Is Palindrome or Not

This program checks if a number is a palindrome by reversing the number entered by the user and comparing it to the original number. It uses a while loop to reverse the number and stores it in a new variable, and an if/else statement to check if the original and reversed numbers are equal, printing the result.

Uploaded by

shreya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views4 pages

C Program To Check Whether A Number Is Palindrome or Not

This program checks if a number is a palindrome by reversing the number entered by the user and comparing it to the original number. It uses a while loop to reverse the number and stores it in a new variable, and an if/else statement to check if the original and reversed numbers are equal, printing the result.

Uploaded by

shreya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CProgramtoCheckWhetheraNumberis

PalindromeorNot
This program reverses an integer (entered by the user) using while loop. Then the if...else
statement is used to check whether the number entered is equal to the reversed number.

Tounderstandthisexample,youshouldhavetheknowledgeoffollowingCprogrammingtopics:
CProgrammingOperators
Cif,if...elseandNestedif...elseStatement
Cprogrammingwhileanddo...whileLoop

Anintegerisapalindromeifthereverseofthatnumberisequaltotheoriginalnumber.

Example:ProgramtoCheckPalindrome
#include<stdio.h>
intmain()
{
intn,reversedInteger=0,remainder,originalInteger;
printf("Enteraninteger:");
scanf("%d",&n);
originalInteger=n;
//reversedintegerisstoredinvariable
while(n!=0)
{
remainder=n%10;
reversedInteger=reversedInteger*10+remainder;
n/=10;
}
//palindromeiforignalIntegerandreversedIntegerisequal
if(originalInteger==reversedInteger)
printf("%disapalindrome.",originalInteger);
else
printf("%disnotapalindrome.",originalInteger);

return0;
}

Output

Enteraninteger:1001
1001isapalindrome.

Checkouttheserelatedexamples:
CProgramtoCountNumberofDigitsofanInteger
CProgramtoPrintanIntegerEnteredbytheUser
CProgramtoComputeQuotientandRemainder

FlyingtoBangalore?

FreeJEEStudyMaterials

InstantGrammarChecker

CProgramtoCheck
ArmstrongNumber

Ad airasia.com

Ad EtoosIndia.com

Ad Grammarly

programiz.com

CProgramtoMakea
SimpleCalculatorUsing...

CProgramtoDisplay
FibonacciSequence

CProgrammingCodeTo
CreatePyramidand...

CProgramtoReversea
Number

programiz.com

programiz.com

programiz.com

programiz.com

RelatedExamples
C Program to Check Whether a Number is Even or Odd
C Program to Check Whether a Character is Vowel or Consonant
C Program to Find the Largest Number Among Three Numbers
C program to Find all Roots of a Quadratic equation
C Program to Check Leap Year

Receive the latest tutorial to improve your programming skills

Enter Your Email

CopyrightbyProgramiz|Allrightsreserved|PrivacyPolicy

Join

You might also like