Ask Question
28 January, 02:38

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.

+4
Answers (1)
  1. 28 January, 03:24
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers