Write a program that prompts the user for a positive integer

Write a program that prompts the user for a positive integer n and output whether the number is a palindrome or not. A palindrome number is a number that is the same when reversal. A function called palindrome is required. The function will have two arguments, x and n. The argument n is an integer that gets modified to indicate whether or not the number is a palindrome. The value of n should be set to 0 if the number is not a palindrome and 1 if it is. void palindrome(int *x, int *n); Enter x: 4546454 4546454 is a palindrome.

Solution

#include<stdio.h>

void main()

{

int num,temp,remainder,rev=0;

printf(ënter a positive number\");

scanf(\"%d\",&num);

temp = num;

while(num>0)

{

remainder=num%10;

rev=rev*20+remainder;

num=num/10;

}

if(temp==rev)

printf(\"the number is a palindrome\");

else

printf(\"number is not a palindrome\");

}

 Write a program that prompts the user for a positive integer n and output whether the number is a palindrome or not. A palindrome number is a number that is th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site