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
alexira [117]
3 years ago
15

Write a recursive function that takes a non-negative integer as an argument and displays the same number in reverse order (i.e.

in order from right to left). For example, if the argument is 76538, it would display 83567.
Computers and Technology
1 answer:
avanturin [10]3 years ago
5 0

Answer:

Following are the program in C++ language

#include<iostream> // header file

using namespace std; // namespace std

int reverse(int n1); // function prototype

int main()  // main function()

{

   int num; // Variable declaration

   cout << "Enter the number" << endl;

   cin >> num; // Read the number bu the user

  cout<<"After Reverse the digit:\n";

   int res= reverse(num); // calling function reverse

   

   cout<<res; // display  

}

int reverse(int n1) // function definition of reverse

{

   if (n1<10)  // checking the base condition

       {

           return n1;

       }

   else

       {

           cout << n1 % 10; // Printed the last digit

          return reverse(n1/10); // calling itsself

}

}

Output:

Enter the number:

76538

After Reverse the digit:

83567

Explanation:

Following are the description of the program

  • In the main function read the number by user in the "num" variable of int type.
  • Calling the reverse and pass that "num" variable into it.
  • After calling the control moves to the body of the reverse function.In this function we check the two condition

        1  base condition

   if (n1<10)  // checking the base condition

       {

           return n1;

     }

      2  General condition

  else

       {

           cout << n1 % 10; // Printed the last digit

          return reverse(n1/10); // calling itsself

       }

  • Finally return the reverse number and display them into the main function.
You might be interested in
Describe your dreams include lifestyle,job,house,friends
n200080 [17]
So, this is an answer of your choice. What it is trying to ask is tell us what your dream home, job, husband, and so on. For example: My dream home is a mansion in Mississippi by the beach. My dream job is a doctor. Those are prime examples of a dream home and job. Now your answer shouldn't be the same as mine. Your's should be something different. Unless, you want a mansion in Mississippi by the beach and you would like to be a doctor. In other words it is asking you to tell us what you want you home, lifestyle, job, friends, and possibly your DREAM pet. Hope this helps.

3 0
2 years ago
Read 2 more answers
How do you add a comment box to a multiple choice question in survey monkey?
Sunny_sXe [5.5K]

Answer:

(Hope this helps can I pls have brainlist (crown) ☺️)

Explanation:

1.Drag and drop Comment Box into your survey from the BUILDER section.

2.Enter question text.

3.Configure any additional options.

4.Click Save.

4 0
2 years ago
Write a program that plays the popular scissor-rockpaper game. (A scissor can cut a paper, a rock can knock a scissor, and a pap
kolbaska11 [484]

Answer:

import random

computer = random.randint(0, 2)

user = int(input("scissor (0), rock (1), paper (2): "))

if computer == 0:

   if user == 0:

       print("The computer is scissor. You are scissor too. It is a draw")

   elif user == 1:

       print("The computer is scissor. You are rock. You won")

   elif user == 2:

       print("The computer is scissor. You are paper. Computer won")

elif computer == 1:

   if user == 0:

       print("The computer is rock. You are scissor. Computer won")

   elif user == 1:

       print("The computer is rock. You are rock too. It is a draw")

   elif user == 2:

       print("The computer is rock. You are paper. You won")

elif computer == 2:

   if user == 0:

       print("The computer is paper. You are scissor. You won")

   elif user == 1:

       print("The computer is paper. You are rock. Computer won")

   elif user == 2:

       print("The computer is paper. You are paper too. It is a draw")

Explanation:

*The code is in Python.

Import the random to be able to generate number number

Generate a random number between 0 and 2 (inclusive) using randint() method and set it to the computer variable

Ask the user to enter a number and set it to the user variable

Check the value of computer the computer variable:

If it is 0, check the value of user variable. If user is 0, it is a draw. If user is 1, user wins. If user is 2, computer wins

If it is 1, check the value of user variable. If user is 0, computer wins. If user is 1, it is a draw. If user is 2, user wins

If it is 2, check the value of user variable. If user is 0, user wins. If user is 1, computer wins. If user is 2, it is a draw

8 0
2 years ago
given an array of integers a, your task is to count the number of pairs i and j (where 0 ≤ i &lt; j &lt; a.length), such that a[
Nimfa-mama [501]

Using the knowledge of computational language in C++ it is possible to write a code that given an array of integers a, your task is to count the number of pairs i and j.

<h3>Writting the code:</h3>

<em>// C++ program for the above approach</em>

<em> </em>

<em>#include <bits/stdc++.h></em>

<em>using namespace std;</em>

<em> </em>

<em>// Function to find the count required pairs</em>

<em>void getPairs(int arr[], int N, int K)</em>

<em>{</em>

<em>    // Stores count of pairs</em>

<em>    int count = 0;</em>

<em> </em>

<em>    // Traverse the array</em>

<em>    for (int i = 0; i < N; i++) {</em>

<em> </em>

<em>        for (int j = i + 1; j < N; j++) {</em>

<em> </em>

<em>            // Check if the condition</em>

<em>            // is satisfied or not</em>

<em>            if (arr[i] > K * arr[j])</em>

<em>                count++;</em>

<em>        }</em>

<em>    }</em>

<em>    cout << count;</em>

<em>}</em>

<em> </em>

<em>// Driver Code</em>

<em>int main()</em>

<em>{</em>

<em>    int arr[] = { 5, 6, 2, 5 };</em>

<em>    int N = sizeof(arr) / sizeof(arr[0]);</em>

<em>    int K = 2;</em>

<em> </em>

<em>    // Function Call</em>

<em>    getPairs(arr, N, K);</em>

<em> </em>

<em>    return 0;</em>

<em>}</em>

See more about C++ code at brainly.com/question/17544466

#SPJ4

4 0
1 year ago
The use of logistics software at DCS (7 points)
Charra [1.4K]

Answer:18 th Century

Explanation:

3 0
2 years ago
Other questions:
  • Assume that play_list refers to a non-empty list, and that all its elements are integers. Write a statement that associates a ne
    7·1 answer
  • How does technology helps save the environment?​
    6·1 answer
  • Suppose for the worst case, given input size n: Algorithm 1 performs f(n) = n2 + n/2 steps Algorithm 2 performs f(n) = 12n + 500
    6·1 answer
  • Assuming that we only support BEQ and ADD instructions, discuss how changes in the given latency of this resource affect the cyc
    7·1 answer
  • Describe and list advantages and disadvantages of each of the following backup types:
    10·1 answer
  • Evie clicks through her presentation slides and realizes they all have transition effects coming from the same location, from th
    13·1 answer
  • Assuming that s and t are Strings, which of the following code fragments are such that the value returned by s.indexOf( t ) befo
    6·1 answer
  • A(n)_________________printer is produce high-quality and is inexpensive *​
    14·1 answer
  • select the correct answer from each drop-down menu. “To clean a computer screen, use ___. To clean a keyboard, use a ___.”
    7·1 answer
  • Who was making the high-pitched growling noise that Francisco hears?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!