answersLogoWhite

0

int getReverse(int n) {

int reversedN = 0;

// Divide n by 10 on each pass to remove the rightmost digit

for (; n > 0; n /= 10) {

// Multiple reversedN to shift all digits to the left

// (to make room for the next digit)

reversedN *= 10;

// Add on (n%10), which is the rightmost digit of n

reversedN += (n % 10);

}

return reversedN;

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Give a business example of how loops can be beneficial in a program?

Give a business example of how loops can be beneficial in a program?


Program codes in turbo c that will display border on the console screen using for loops?

There is not one that I know off but you could write it.


Wap to calculate reverse of a number without loops?

Main(include.h)


Is there another program like Fruity Loops?

Reason is very similar as Fruity Loops, its a better program and takes a little more time to master


Why you use different loops in c language?

We use this in order to make program easier and less complex.some program cannot be performed without loops


Why you use Loops?

Loops are used to repeat the execution of the same set of instructions again and again in a program.


In what instanses can i use the loops?

Whenever there is a repetition in the program.


What are the disadvantages of the While Loop?

With loops, your program is slower.


How do you write a Program of printing prime numbers between 1 to 100 in 1 statement only?

You really need some nested loops; but some programming languages might allow you to write this as one statement.


Can you use two while loops in a program?

You can use zero or more while-loops, there is no limit.


What is a good beat making website?

frutie loops it is a great program


What does it mean to clean out loops in programming?

Cleaning out the loops is essentially removing redundant lines of code in a program. Sometimes having too many of the same codes can slow the program down and cause it to not work as efficiently.