|
|
The program is not recognizing that each digit is it's own number, |
input % N
input = input / N
I'm currently trying to make a program that validates user input and displays the digits in the number as odd and even, and also displays the number reversed. In addition to these things, there has to be a space between the digits of the number. I'm a C++ beginner and I am having a lot of problems. I've searched everywhere but I'm unable to fix these issues. I'm only able to use the following topics in order to write the code which are: • Increment and decrement operators • The while loop • Do-while loop • For loop • Nested loop It should read as: Enter a number: 54321 Original number: 54321 Number reversed: 1 2 3 4 5 Even digits: 4 2 Odd digits: 5 3 1 The issues I'm currently having are: 1. If the user enters a number that is a special character or a letter it has to validate the input. 2. The program is not recognizing that each digit is it's own number, so the even calculation only works if I input a single digit such as 6, and the odd calculation is not working. 3. I'm not sure how to put a space between each digit or reverse the number. |
is it possible you can show an example of how to implement that into the code? |
admin wrote: |
---|
Don't post homework questions Programmers are good at spotting homework questions; most of us have done them ourselves. Those questions are for you to work out, so that you will learn from the experience. It is OK to ask for hints, but not for entire solutions. |