Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

My program below reverses digits of a INTEGER...I need it to reverse DECIMAL num

ID: 3646949 • Letter: M

Question

My program below reverses digits of a INTEGER...I need it to reverse DECIMAL numbers as well...

Will the code below do decimal digits as well?? Or am I completely screwing this up...

void reverseDigits(int number){
if(number >= 0) // Make sure we have a positive number
{
if(number < 10)
System.out.print(number);
else
{
System.out.print(number % 10); // This prints the right most number first
reverseDigits(number / 10); // The remainder of the digits are to follow
}
}




Thanks in advance.

Explanation / Answer

int countDigitsInInteger(int n) { int count =0; while(n>0) { count++; n=n/10; } return count; } using namespace std; int main(int argc, char *argv[]) { int intLength =0; int number; int digit; int sum = 0; string s; cout >number; cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote