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
State 2 advantages of laptops over desktop computers
PSYCHO15rus [73]
1. Laptops are portable
2. Laptops take less space
8 0
3 years ago
Read 2 more answers
In the 2007/2010 version of Paint, which of the following tools are located in the View tab? (Select all that apply.)
zaharov [31]
The answers are full screen and gridlines.
7 0
4 years ago
What do these terms have in common? google, yahoo!, bing they are important books. they are internet search engines. they are wo
Vlada [557]
They are Internet search engines.
7 0
4 years ago
OO<br>(A) 3 and 5<br>(B) 4 and 8<br>(C) 2 and 0<br>(D) 6 and 9<br>2. There are twelve books on a shelf and four children in a ro
dlinn [17]

Explanation:

2.there will be 8 books left on the shelf if each child takes one

8 0
3 years ago
c++ Write a for loop that computes the following sum: 5+10+15+20+...+485+490+495+500. The sum should be placed in a variable sum
ElenaW [278]

Answer:

#include <iostream>

#include <cstdlib>

 

using namespace std;

 

int main(){

 

 

   int sum=0, num=5;   //variables declaration and inicialization

 

   while (sum<500){   //conditioning to do the sum up to 500

   sum=sum+num;     //actually sum process

   cout << "The value is: "<<sum;   //show the result in screen

   };

   return 0;

}

5 0
4 years ago
Other questions:
  • Only the _________ can add users with passwords and limit user access to selected areas.
    5·1 answer
  • Two technicians are discussing amperage in a series circuit. Technician A states that adding resistors in series will decrease c
    13·1 answer
  • To prevent injury when pulling a nail be sure the material holding the nail is
    14·1 answer
  • What is the TAG to begin a Web page, as recommended by the W3C?
    13·1 answer
  • Software for creating animations
    15·2 answers
  • Which of the following skills do employers in any field expect their employees<br> to have?
    5·1 answer
  • is there anybody out there who is a social butterfly like me? If so then you can tlk to me on this. and to anybody out there tha
    12·1 answer
  • The software maintains and manages information related to employees, rooms, committees, and committee meetings of a company. The
    9·1 answer
  • Why do electronic devices gather so much dust? Thanks
    8·1 answer
  • What do you think color theory<br> in web design is?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!