• Language

    C

  • Description

    A five digit number is entered through the keyboard. Write a program to obtain the reversed number and to determine whether the original and reversed numbers are equal or not.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    int original, reversed;
    printf ("Enter the value of original: ");
    scanf ("%d", &original);
    (void) getchar ();
    reversed=(original%100000-original%10000)/10000+(original%10000-original%1000)/100+original%1000-original%100+(original%100-original%10)*100+(original%10)*10000;
    if(original==reversed)
        printf ("The original and the reversed numbers are equal.\n");
    else
        printf ("The original and the reversed numbers are not equal.\n");
    printf ("Value of reversed: %d\n", reversed);
    putchar ('\n');
    system ("pause");
    return EXIT_SUCCESS;
}