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
You are hired by a game design company and one of their most popular games is The Journey. The game has a ton of quests, and for
Kamila [148]

Answer:

Explanation:

Let's describe the connected part for the very first time.

Component with good connections:-

A semi in any graph 'G' is defined by a way to align element if this can be crossed from the beginning of any link in that pixel or if this can be stated that there is a path across each organized node pair within this subgram.

Consecrated pair means (ni, nj) and (nj, ni) that 2 different pairs would be regarded.

In point a:

We're going to be using contradictions for this segment. They start with the assumption that two lucky journeys are not even in the same strongly interconnected component.

For instance, qi and qj are providing special quests that were not in the very strongly linked element and which implies that, if we start to cross from qi or qi, then qj cannot be approached if we begin to move through qj and as we established if qi or qj is fortunate contests, we may reach any other hunts. Which implies qj from qi or conversely should be reachable. Or we might claim that qi is part of the strongly linked portion of qj or vice versa with this situation.

Consequently, we would not be capable of forming part of a different and strongly linked element for two successful scientists; they must have the same strongly related to the element.

In point b:

Its definition of its strong, line segment indicates that all other searches within such a strongly coordinate system can be made possible from any quest. Because if all quests are accessible from any quest then a lucky search is named, and all other quests can be accessed from any quest in a very coordinated system. So, all contests are fortunate contests in a strongly connected element.

Algorithm:

Build 'n' size range named 'visited' wherein 'n' is the number of graphic nodes that keep records of nodes already frequented.  Running DFS out of every unknown vertex or mark all edges as seen.  The lucky search will be the last unexplored peak.

Psuedo-Code:

Requires this functionality to also be called Solution, it requires 2 reasons as an input, V is a set of objects in graph 'G' and 'G' is a chart itself.

Solution(V, G):

visited[V] = {false}//assign value

for v: 0 to 'V'-1:  //using for loop

if not visited[v]:  //use if block

DFS(v, visited, V, G)  //use DFS method

ans = v //holding value

return ans //return value

3 0
3 years ago
Read 2 more answers
Mark works as a Network Administrator for NetTech Inc. The company has a Windows Server 2008 domain-based network. The network c
mart [117]

Hello This Answer Is Not Real This Is All A Simulation

5 0
3 years ago
drag each type of document to the correct location on the table. Drag each document to its respective category
trapecia [35]

Answer:

What? I don't get it.

Explanation:

4 0
3 years ago
because of online writing, our audience: A. Compromise older people B. are bigger than before C. usually read less often D. are
lions [1.4K]
B. Are Bigger Than Before
8 0
3 years ago
Read 2 more answers
New trends, tools, and languages emerge in the field of web technology every day. Discuss the advantages of these trends, tools,
ikadub [295]

Answer:

Explanation:However, with the emergence of several new web development technologies, tools, frameworks, and languages in the last few years, it has now become quite .

7 0
3 years ago
Other questions:
  • A Color class has three int color component instance variables: red, green, and blue. Write a toString method for this class. It
    13·1 answer
  • Which of the following statements is true?
    8·1 answer
  • The requirement that each term in the objective function only contains a single variable is in a linear program is referred to a
    5·1 answer
  • Can your digital footprint be destroyed or does it remain active on the internet forever
    5·1 answer
  • How might a company go about performing a load test on their website?
    7·1 answer
  • How do you write the slope-intercept form?
    5·1 answer
  • What are the text or graphics that are lighter than the main text located in a document's background called?
    10·1 answer
  • Missy loves her old Windows games. When she upgrades her Windows system, the games run fine, but the output looks fuzzy since th
    15·1 answer
  • 25 Points Asap <br> Write a Java program named Light.java that displays a light bulb shown below:
    14·1 answer
  • JAVA<br>plzz help...............​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!