i got into this simple program in c programing, the program is simply reversing any input number by user, using a while loop, i dont know if its okay to post such a question but i didnt realy understood how the while loop works
int n, reverse = 0;
printf("Enter a number to reverse
");
scanf("%d",&n);
while (n != 0)
{
reverse = reverse * 10;
reverse = reverse + n%10;
n = n/10;
}
printf("Reverse of entered number is = %d
", reverse);
i would be so thankfull if anyone could explain it to me
See Question&Answers more detail:os