0% found this document useful (0 votes)
176 views

ProgrammingKnowledge - C++ Program To Check Palindrome Number PDF

This C++ program checks if a number is a palindrome by reversing the number and comparing it to the original. The user inputs a number which is stored in the variable "num". A for loop iterates through num, extracts the last digit using modulo 10, stores it in r, and multiplies the running sum by 10 before adding r to get the reversed number. If the reversed number is equal to the original temp, it is a palindrome, otherwise it is not. The program outputs that 2525 is not a palindrome.

Uploaded by

Prakash K
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
176 views

ProgrammingKnowledge - C++ Program To Check Palindrome Number PDF

This C++ program checks if a number is a palindrome by reversing the number and comparing it to the original. The user inputs a number which is stored in the variable "num". A for loop iterates through num, extracts the last digit using modulo 10, stores it in r, and multiplies the running sum by 10 before adding r to get the reversed number. If the reversed number is equal to the original temp, it is a palindrome, otherwise it is not. The program outputs that 2525 is not a palindrome.

Uploaded by

Prakash K
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

12/30/13

ProgrammingKnowledge: C++ Program to Check Palindrome Number

C++ Program to Check Palindrome Number


PALINDROMIC NUMBERS - C++

# i n c l u d e < s t d i o . h > # i n c l u d e< i o s t r e a m > u s i n gn a m e s p a c es t d ; i n tm a i n ( ) { i n tn u m , r , s u m = 0 , t e m p ; c o u t< <" E n t e ran u m b e r :" ; c i n> >n u m ; f o r ( t e m p = n u m ; n u m ! = 0 ; n u m = n u m / 1 0 ) { r = n u m % 1 0 ; s u m = s u m * 1 0 + r ; } i f ( t e m p = = s u m ) c o u t< <t e m p< <"i sap a l i n d r o m e " ; e l s e c o u t< <t e m p< <"i sn o tap a l i n d r o m e " ; r e t u r n0 ; }

O U T P U T :
E n t e ran u m b e r :2 5 2 5i sn o tap a l i n d r o m e

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

programmingknowledgeblog.blogspot.de/2013/04/c-program-to-check-palindrome-number.html

1/1

You might also like