The question:

> 
> A 4 digit number is entered through keyboard. Write a C program to print a new number with digits reversed as of orignal one. E.g.-  
> 
> Input: `1234` Output: `4321`  
> 
> Input: `5982` Output: `2895`
> 
> 
> 

and my code is:

```cpp
#include <stdio.h>

int main()
{
    int x;
    printf("Enter number\n");
    scanf("%d", &x);
    int first_digit = x % 10;
    int second_digit = (x / 10) % 10;
    int third_digit = (x / 100) % 10;
    int fourth_digit = (x / 1000) % 10;
    int new_number = (first_digit * 1000) + (second_digit * 100) +
                     (third_digit * 10) + (fourth_digit * 1);
    printf("%d\n", new_number);
    return 0;
}

```

It will be appreciated if you could help me! Thanks! Explain me how this reverses the number!