Computer Science, asked by aditya4384, 1 year ago

write a program to find reverse of any number

Answers

Answered by Anonymous
0
This is a C Program which reverses a number & checks if it is a palindrome or not.

Problem Description

This C program accepts an integer, reverse it and also checks if it is a palindrome or notn step 4.
5. Repeat the process until quotient becomes zero.
6. When it becomes zero, check if the reversed number is equal to original number or not.
7. Print the output and exit.

Program/Source Code

Here is source code of the C program to reverse a number & checks it is a palindrome or not. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

 

 

#include <stdio.h>

 

void main()

{

int num, temp, remainder, reverse = 0;

 

printf("Enter an integer \n");

scanf("%d", &num);

/* original number is stored at temp */

temp = num;

while (num > 0)

{

remainder = num % 10;

reverse = reverse * 10 + remainder;

num /= 10;

}

printf("Given number is = %d\n", temp);

printf("Its reverse is = %d\n", reverse);

if (temp == reverse)

printf("Number is a palindrome \n");

else

printf("Number is not a palindrome \n");

}

Similar questions