Let the number entered by the user is 417 ,i.e., n=417

Initialise rev = 0

**while(n!=0) ** /* for loop is executed till n is not equal to 0 */

**1st Iteration: while(417!=0) /* condition is true */**
a = n % 10
= 417 % 10
= 7
n = n / 10
= 417 / 10
= 41
rev = rev * 10 + a
= 0 * 10 + 7
= 7

**2nd Iteration: while(41!=0) /* condition is true */**
a = n % 10
= 41 % 10
= 1
n = n / 10
= 41 / 10
= 4
rev = rev * 10 + a
= 7 * 10 + 1
= 70 + 1
= 71

**3rd Iteration: while(4!=0) /* condition is true */**
a = n % 10
= 4 % 10
= 4
n = n / 10
= 4 / 10
= 0
rev = rev * 10 + a
= 71 * 10 + 4
= 710 + 4
= 714

So, reverse of 417 is 714