Hey,
I was just wondering how you would write a program to input a number (e.g. 1234) and then output the number reversed (e.g. 4321)
Thanks
Hey,
I was just wondering how you would write a program to input a number (e.g. 1234) and then output the number reversed (e.g. 4321)
Thanks
There are many different ways. You can read it in as a string and reverse the string. You could use math (division and modulus) to get each digit and output them in reverse order. You could also search the board and find other options since this is a common question.
You could also try it yourself first, just in case you feel like learning something
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
If you realy have no idea you can put each digit in a one array cell and then make a loop wich will output the array from the top to the bottom.