asked 20.1k views
2 votes
Write a function that takes an integer value and returns the number with its digits reversed. for example, given the number 7631, the function should return 1367. must use a loop.

1 Answer

5 votes

//=indicating you to do the programming part on your own relating to the description provided against. This done because different programming languages require different coding for that.

n=integer value

n1=dummy storage for n

r=variable used to do the function

{

int n,r,n1,rev=0;

//do the coding here for storing the integer in the variable n

n1=n;

while(n>0){

r=n%10;

rev=(rev*10)+r;

n=n/10;

}

//now add a command for displaying the value of rev

}

this is just a logic i used for java

done.

answered
User Tehila
by
7.7k points