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 short note on attributes in HTML.<br> If you answer this i will mark you as BRAINLIST
Hunter-Best [27]

Answer:

Explanation:

HTML attributes are a modifier of an HTML element type. An attribute either modifies the default functionality of an element type or provides functionality to certain element types unable to function correctly without them. In HTML syntax, an attribute is added to an HTML start tag.

4 0
2 years ago
What is the practice of distributing responsibility among multiple people so that no one person has full control of
Sholpan [36]

Answer:

If the responsibilities are distributed ,the disputes amongst people wont take place because their wont be any partiality, everyone would be equal. Moreover it is difficult for one person to control everything at once and multiple people would help the work to be organized as everyone will have their own part of work which is supposed to be fulfilled.

8 0
2 years ago
Which of the following is used to track and gather information without knowledge or authorization?
harkovskaia [24]
It might be spyware... but i might be wrong.
3 0
3 years ago
Read 2 more answers
How many bits are required to store the text of the number 150 in ascii?
kaheart [24]
The correct answer of the given question above would be 24 BITS. The number of bits that are required to store the text of the number 150 in ASCII would be 24 bits. ASCII means American Standard <span>Code for Information Interchange. Hope this answer helps. </span>
7 0
3 years ago
Read 2 more answers
Which of the following factors will have the greatest impact on your credit score? I. Length of Credit History II. Payment Histo
Veseljchak [2.6K]
<span>the one that would have the greatest impact on my credit score would be : B. II and III If you had a troublesome payment history, it would be very likely that you'll end up with credit score because you make yourself became untrustworthy and if you have a low Debt, people will trust your current financial condition and you will be more likely to earn high credit score</span>
5 0
3 years ago
Read 2 more answers
Other questions:
  • What is a valence orbit?
    13·2 answers
  • if the president goes for vice president after his 2 term and the present president dies is the old president the president agai
    8·2 answers
  • For a typically large organization how many dns servers should you install
    5·1 answer
  • The button for adding a picture to a spreadsheet is found in the
    15·1 answer
  • What are the basic tools for coding HTML manually?
    9·2 answers
  • Sorry but, what are brainliest for?
    7·2 answers
  • Describa la clasificación de los recursos educativos digitales abiertos. vea este video, para hacer eso
    11·2 answers
  • Write code which takes a sentence as an input from the user and then prints the length of the first word in that sentence.
    6·1 answer
  • In MS Word we can merga cells true or false​
    13·2 answers
  • Find the output<br>I need it immediately​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!