C or C++?
If you compile it as a C code it runs.
If you compile it as a C++ code, it does not run as the return type of main() should be int.
Format Your Code
Your code is not properly formatted. Indentations are neglected. Would you use proper indentation you'd see right away that the while loop is wrong as the update on the sum and x variables is not part of the loop, but it should be.
Call Your Function
Since you never call
from your main() function, your program only asks for a number then exits.
Set Your Variables
The variable org never takes its value, so later when you compare it to sum it will not give you the right answer. You should set it to the original value before changing it:
int org = x;
Also note that the variable a is unused, so you can remove it.