Answer to Question #278061 in C++ for aiman

Question #278061

Write a program that uses the function isNumPalindrome. Test your program on the following

numbers: 10, 34, 22, 333, 678, 67876, 44444, and 123454321.


1
Expert's answer
2021-12-10T13:22:04-0500
#include <iostream>
#include <string>
using namespace std;




bool isNumPalindrome(int number){
	int temp=number;    
	int sum=0;
	while(number>0)    
	{    
		int r=number%10;    
		sum=(sum*10)+r;    
		number=number/10;    
	}    
	return (temp==sum);
}
	
int main()
{
	int number;
	cout<<"Enter the number: ";    
	cin>>number;    
	
	if(isNumPalindrome(number)){
		cout<<"The number is a palindrome\n\n";    
	}else{
		cout<<"The number is NOT a palindrome\n\n";    
	}
	
	system("pause");
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog