Answer to Question #274814 in C for Amu Raj

Question #274814

Write a C program to input number from user and check number is palindrome or not using while loop.

1
Expert's answer
2021-12-06T14:04:31-0500
#include<stdio.h>  
int main()    
{    
	int number,r,sum=0,temp;    
	printf("Enter the number: ");    
	scanf("%d",&number);    
	temp=number;    
	while(number>0)    
	{    
		r=number%10;    
		sum=(sum*10)+r;    
		number=number/10;    
	}    
	if(temp==sum){
		printf("The number is a palindrome");    
	}else{
		printf("The number is NOT a palindrome");    
	}


	getchar();
	getchar();
	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
APPROVED BY CLIENTS