Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that prompts the user for a positive integer n and output whethe

ID: 3925300 • Letter: W

Question

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.

Explanation / Answer

#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");

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote