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]
3 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]3 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
Write a program that has a conversation with the user. The program must ask for both strings and numbers as input. The program m
konstantin123 [22]

Answer:

yo im sorry eat my cookie

Explanation

doorkoeeworkwoeroewkrwerewrwe

5 0
3 years ago
Can you give me a long list of kid's cartoons
Delicious77 [7]
SpongeBob, Teen Titan Go, Future Worm. That's all I can think!
8 0
3 years ago
Read 2 more answers
1.
aliya0001 [1]
#1 is D #2 is B #3 is A #4 is D #5 is B
3 0
3 years ago
Read 2 more answers
What is the role of the digital cinematographer?
dlinn [17]
<span> is the person in charge of actually shooting the film. He is the head of the camera and lighting departments, and as such he has a big </span>role<span> in the making of any movie

</span>
3 0
3 years ago
Read 2 more answers
Match the feature to the network architecture,
pochemuha

Answer:

Answer is:  

Client-Server Network

  • expensive to set up
  • has a central server
  • easy to track files
  • useful for a large organization

Peer-to-peer Network

  • useful for a small organization
  • difficult to track files
  • inexpensive to set up
  • does not have a central server

Explanation:

<em>Client-Server Network is ideal for bigger network set up like offices and companies where there will be a central server involved with several clients to access and connected with the server. This is the normal network set up to companies. While, Peer to peer network is ideal for much smaller network, which consists of only two computers to communicate and share files. This network is normally temporary and inexpensive since in only works with two computers.</em>

7 0
3 years ago
Other questions:
  • What is the device called which typically combines the capabilities of a scanner, printer, fax, and copying machine?
    15·1 answer
  • How would this requirement be implemented?
    12·1 answer
  • The computer mouse is used to
    7·1 answer
  • In a @return tag statement the description:
    13·2 answers
  • Objects of the calculator class require no additional information when created. define an object named calc, of type calculator.
    14·2 answers
  • People are able to predict future events to some extent because: (Select all that apply)
    11·1 answer
  • adding ______around calculations indicates which calculations should be performed first before following the typical order of op
    6·1 answer
  • Here's a better picture of my pc mouse and keyboard​
    5·2 answers
  • Cine stie repede va rog mult si repede
    9·1 answer
  • What should you do first when designing a program?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!