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
jeka57 [31]
4 years ago
11

Write a recursive C++ function that writes the digits of a positive decimal integer in reverse order.

Computers and Technology
1 answer:
dangina [55]4 years ago
4 0

Answer:

// here is code in c++.

#include <bits/stdc++.h>

using namespace std;

// recursive function to print digit of number in revers order

void rev_dig(int num)

{

  if(num==0)

  return;

  else

   {

       cout<<num%10<<" ";

       // recursive call

       rev_dig(num/10);

   }

}

// driver  function

int main()

{

   int num;

   cout<<"enter a number:";

   // read the number from user

   cin>>num;

   cout<<"digits in revers order: ";

   // call the function with number parameter

   rev_dig(num);

   

return 0;

}

Explanation:

Read the input from user and assign it to variable "num". Call the function "rev_dig" with "num" parameter.In this function it will find the last digit as  num%10 and print it. Then call the function itself with "num/10". This will print the second last digit. Similarly it will print all the digits in revers order.

Output:

enter a number:1234                                                                                                        

digits in revers order: 4 3 2 1

Diagram :

You might be interested in
Hey! I was recommended a site “9anime” the other day. All’s been going well but I accidentally taped on a new dub settingZ somet
Studentka2010 [4]

Answer:

yep defiantly virus

Explanation:

8 0
2 years ago
Read 2 more answers
Describe the history of computer in Nepal.​
sergey [27]

Answer:

The first computer brought in Nepal was IBM 1401 which was brought by the government in lease for the population census of 1972 (2028 BS). Later in 1975 (2031 BS)YantrikSarinikaran Kendra (Electronic Data Processing Centre) was established which was later called as National Computer Centre ( NCC )

4 0
3 years ago
Read 2 more answers
How many times will the loop body execute:
Xelga [282]
I’d also say B, which is 2
6 0
3 years ago
Two technicians are discussing MAP sensors. Technician A says that the MAP sensor should be replaced if anything comes out of th
anygoal [31]

Answer:

Both are correct.

Explanation:

Both technicians are correct in this scenario. Technician A point of view is correct as well as technician B.

3 0
3 years ago
How do I create a videogame
mote1985 [20]

Answer:

-Learn how to code

-Make Character

-Design

-Go to classes

-Go on video game platforms and make an video game(rblx is the best in my opinion)

-Play video games and see the scripts

-Decide what type of video game your making(horror, family game, battle game, etc.)

Explanation:

3 0
3 years ago
Other questions:
  • Given positive integer numInsects, write a while loop that prints that number doubled without reaching 200. Follow each number w
    8·1 answer
  • Which is NOT a type of SD card?
    8·2 answers
  • How can i appear offline without fb messenger saying "last active 1 minute ago"?
    5·1 answer
  • When you “listen” to evaluate an online message, which question should you ask?
    11·1 answer
  • write an algorithm that gets the price for item A plus the quantity purchased. The algorithm prints the total cost, including a
    5·1 answer
  • 1. Some of the music in the 1960s was used to protest social and political issues. Is music still used as a form of protest? Why
    13·1 answer
  • Need help with photography
    12·1 answer
  • Which statement best describes the refraction of light
    9·1 answer
  • A new PKI is being built at a company, but the network administrator has concerns about spikes of traffic occurring twice a day
    5·1 answer
  • Which of the following is NOT present on the Title Bar?​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!