add n to x

In 1994, when I was in tenth grade at Bradshaw High School, there was one programming problem that I could never figure out. For years, I’ve occasionally pulled that problem out and toyed with it: reversing a sequence of numbers. A few nights ago, as I went to sleep, I came up with the solution.

#include < stdio.h >

int main(void) {

long foo= 0, bar = 0, x = 0;

printf(“Enter a number: “);
scanf(“%li”, &foo);

while (foo > 0) {
x = foo % 10;
foo = foo / 10;
bar = (bar*10)+x;
}

printf(“This is bar: %li\n”, bar);
return(0);

}