help please

write a compile and run a c++ program to reverse the digits of a positive integer number .use a do-while statement and continuously strip off and display the numbers units digit
No :D
please im a beginner i have no clue what to do
Have you tried turning it off and on again?
I recommend paying attention in class and doing whatever required reading there might be.
yes i did Easton multiple times. how would you go by writing the program ?
You COULD write it like this. I'll leave "explaining this code atrocity to the instructor" as an exercise for the OP.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <string>
#include <sstream>

std::string makePalindrome(std::string inStr)
{
    std::stringstream sstr;
    sstr << inStr;
    for (std::string::reverse_iterator rit = inStr.rbegin();
                                       rit != inStr.rend();
                                       ++rit)
    {
        sstr << (*rit);
    }

    return sstr.str();
}

int main()
{
    std::string userInput;
    std::cout << "Enter a number to reverse: ";
    std::getline(std::cin, userInput);

    do
    {
        std::string newString = makePalindrome(userInput);
        std::cout << newString.substr(userInput.size()) << "\n";
    } while(0);
    return 0;
}
Last edited on
I would go about it by pasting the source code I should have made, and clearly explaining where the error in my source code is, and hoping that someone will help me after this post.
Registered users can post here. Sign in or register to post.