Ask Question
19 June, 14:22

Write a function that takes an integer and reverses the digits. The function returns the reversed number to main. Here is the prototype for this function. Write main () to test this function. Use only int data type and arithmetic to solve this problem.

+1
Answers (1)
  1. L
    19 June, 16:26
    0
    The prototype part missing has been assumed to be:

    int reverseNum (int num);

    Code:

    #include

    using namespace std;

    int reverseNum (int num);

    int main ()

    {

    int num=0, result=0;

    cout<<"Enter the number:";

    cin>>num;

    result=reverseNum (num);

    cout<<"The reversed number : "<
    return 0;

    }

    int reverseNum (int num)

    {

    int temp=0, digit=0;

    for (num; num>0; num=num/10)

    {

    digit=num%10;

    temp=temp*10+digit;

    }

    return temp;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a function that takes an integer and reverses the digits. The function returns the reversed number to main. Here is the prototype for ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers
Sign In
Ask Question