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
Blizzard [7]
3 years ago
10

Write a recursive function sumAll that accepts an integer argument and returns the sum of all the integers from 1 up to the numb

er passed as an argument. For example, if 50 is passed as an argument, the function will turn the sum of 1, 2, 3, 4, ..50.
Computers and Technology
1 answer:
slavikrds [6]3 years ago
8 0

Answer:

int sumAll(int n)//function definition.

{

   if(n==1)//if condition.

   return 1;

   else//else condition.

   {

       return n+sumAll(n-1);//return the value and call the function in recursive manner.

   }

}

Explanation:

  • The above-defined function is a recursive type function that is written in the c language, which holds the if and else condition.
  • When the user passes the largest value from 1, then the else condition will be executed which adds the largest value and pass the value after the decrement of the value as an argument.
  • When the value will become 1, then the function if-block will be executed which returns the value and ends the calling function recursively.
You might be interested in
Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending whe
Nana76 [90]

<u>Answer:</u>

<em>using System; </em>

<em>public class Program </em>

<em>{ </em>

<em> public static void Main() </em>

<em> { </em>

<em> String input ; </em>

<em> while(true) </em>

<em> { </em>

<em>  input = Console.ReadLine(); </em>

<em>  if(input.Equals(""quit"")) </em>

<em>  break; </em>

<em>  Reverse_String(input); </em>

<em> } </em>

<em> return; </em>

<em> } </em>

<em>static void Reverse_String(string input_text) </em>

<em>{ </em>

<em>    char[] text = input_text.ToCharArray(); </em>

<em>    Array.Reverse(text); </em>

<em>    Console.WriteLine(text); </em>

<em>} </em>

<u>Explanation:</u>

<em>In the above program a separate function is written to reverse the string.</em>

This method takes the string as an argument and place it in a array and then use the built-in function reverse and print the reversed string in the console.

<em>In the main(), the input is obtained from the console and it is passed to the reversestring(). </em>

7 0
3 years ago
Read 2 more answers
What is a computer network that provides connectivity in a geographic area or region larger than that covered by a local area ne
lina2011 [118]

Answer:

The correct answer for the given question is "Metropolitan Area Network"

Explanation:

The metropolitan area network connect the user with a geographic area of the size of  metropolitan area.Metropolitan area network connect LAN i.e " local area network " to a single larger network thats provide efficient  connection to the WAN network.Their are many advantage to use metropolitan area network which are mention above .

  • Provides the better security then other network.
  • Cheaper lost when we connect MAN with WAN.
  • If we use MAN network then data will be fastly transferred.
6 0
3 years ago
Which term refers to a solution to a large problem that is based on the solutions of smaller subproblems. A. procedural abstract
valentina_108 [34]

Answer:

procedural abstraction

Explanation:

5 0
3 years ago
Need help asap<br> give the correct answer!!
blagie [28]
It’s either b or c, but my final answer would be C
4 0
2 years ago
Read 2 more answers
One of the first feature films to use 3D animation was called ________. Water World Futureworld Wayne’s World Cool Hand Luke
Vladimir79 [104]
It was called Futureworld

It was published in 1976, it was the first animation that using 3D computer graphics for its animated hand and face.

But they still used 2D digital composting to materialize characters over a background
8 0
3 years ago
Read 2 more answers
Other questions:
  • Using the flowchart below, what value when entered for Y will generate a mathematical error and prevent our flowchart from being
    14·1 answer
  • Which method allows a computer to react accordingly when it requests data from a server and the server takes too long to respond
    5·1 answer
  • The protocol that enables computers on the Internet to communicate with one another is called _____.
    10·2 answers
  • True or false: Your digital footprint is all the information about you online that only you post. Group of answer choices
    12·2 answers
  • A thin red border indicates the active cell. (True or False)
    12·1 answer
  • Drag the correct type of update to its definition.
    14·1 answer
  • What will result if the following code is used in an HTML file? New Title
    13·2 answers
  • For this activity, you will practice being both proactive and reactive to bugs. Both are necessary to get rid of errors in code.
    5·1 answer
  • Use the table on the right to convert from binary to decimal.
    11·2 answers
  • You have just received a generic-looking email that is addressed as coming from the administrator of your company. The email say
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!