Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (anonymous):

can anyone help me to make this program???\ take input like this 12345 in integer variable and print like this 54321 in another integer variable.

OpenStudy (anonymous):

take the number as an integer variable and use the mod function dividing the number with 10. at each step u get a remainder which is a digit of the given number. u get the numbers in reverse order which u can store in some array variables. after each step divide the number with 10 and repeat above steps. finally display all the array number in order starting from first one which u get when u divide it by 10. u get the number displayed in reverse.

OpenStudy (anonymous):

int ret = 0,val; scanf("%d",&val); while ( val != 0 ){ ret = 10 * ret + ( val % 10 ); val /= 10;} printf("reverse:: %d ",ret);

OpenStudy (anonymous):

use string here: )

OpenStudy (anonymous):

well the program in python is: num = raw_input('Enter the number: ') #takes the input rev_num = num[::-1] #reverses the number print rev_num #prints the reversed number

OpenStudy (anonymous):

http://codepad.org/QxLgLVFN Doesn't only print out the number; you can also use it in computations.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!