1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
alexira [117]
3 years ago
15

Write a recursive function that takes a non-negative integer as an argument and displays the same number in reverse order (i.e.

in order from right to left). For example, if the argument is 76538, it would display 83567.
Computers and Technology
1 answer:
avanturin [10]3 years ago
5 0

Answer:

Following are the program in C++ language

#include<iostream> // header file

using namespace std; // namespace std

int reverse(int n1); // function prototype

int main()  // main function()

{

   int num; // Variable declaration

   cout << "Enter the number" << endl;

   cin >> num; // Read the number bu the user

  cout<<"After Reverse the digit:\n";

   int res= reverse(num); // calling function reverse

   

   cout<<res; // display  

}

int reverse(int n1) // function definition of reverse

{

   if (n1<10)  // checking the base condition

       {

           return n1;

       }

   else

       {

           cout << n1 % 10; // Printed the last digit

          return reverse(n1/10); // calling itsself

}

}

Output:

Enter the number:

76538

After Reverse the digit:

83567

Explanation:

Following are the description of the program

  • In the main function read the number by user in the "num" variable of int type.
  • Calling the reverse and pass that "num" variable into it.
  • After calling the control moves to the body of the reverse function.In this function we check the two condition

        1  base condition

   if (n1<10)  // checking the base condition

       {

           return n1;

     }

      2  General condition

  else

       {

           cout << n1 % 10; // Printed the last digit

          return reverse(n1/10); // calling itsself

       }

  • Finally return the reverse number and display them into the main function.
You might be interested in
Want is the assignmment
AnnZ [28]
Can you explain this
4 0
3 years ago
Which of the following is non-volatile storage?
gulaghasi [49]
Primary because it is non-volatile storage
6 0
2 years ago
Who can give me answer for this kinda urgent pls
marissa [1.9K]

Answer:

true

Explanation:

it's TRUE the correct answer is true

6 0
2 years ago
A buffer storage that improve computer performance by reducing access time is​
kvasek [131]
Cache memory

Hope it helps
4 0
3 years ago
PLEASE HELP!!<br> Would you ever try and get famous off of social media? Why or why not?
Alexxandr [17]

Answer:

Yes because u could gain a lot of money from it

Explanation:

With more money you have, the more you can give to charity, and the more you can relax

3 0
2 years ago
Read 2 more answers
Other questions:
  • What identifies available computers through the internet?
    14·1 answer
  • What is binary number
    11·1 answer
  • 1. Which plot element is typically the turning point and the most intense moment of a story? (1 point)
    11·2 answers
  • Data cannot be sorted or filterd accuratly if there are ________.
    12·1 answer
  • The Internet began when a large company wanted to sell products online. <br> True or flase?
    6·2 answers
  • 2. Write a Python regular expression to replace all white space with # in given string “Python is very simple programming langua
    14·1 answer
  • outline 4 IDE features that makes software development much faster and more convenient than other alternatives.​
    9·1 answer
  • Heyyyyyy who likes anime​
    12·2 answers
  • Digital censorship uses automated, intelligent systems with big data storage to _____. Select 3 options.
    13·2 answers
  • What type of malicious software technology is used to download and install software without the user's interaction?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!