Ask 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 this function. Write main () to test this function. Use only int data type and arithmetic to solve this problem.

+5
Answers (1)
  1. 11 January, 02:27
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers