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
OverLord2011 [107]
3 years ago
11

Write a recursive function to compute sum of first N integers starting with 1.

Computers and Technology
1 answer:
Citrus2011 [14]3 years ago
4 0

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// recursive function to find sum from 1 to n

int recur_Sum(int n)

{ // base condition

if (n <= 1)

 return n;

// recursive call

return n + recur_Sum(n - 1);

}

// main function

int main()

{

   // variables

   int n;

   cout<<"Enter a number:";

   // read the number

   cin>>n;

   // print the sum

   cout<<"Sum of first "<<n<<" integer from 1 to "<<n<<" is:"<<recur_Sum(n);

return 0;

}

Explanation:

Read a number from user and assign it to variable "n".Call function recur_Sum() with parameter "n".This function will recursively call itself and find the Sum of first n numbers from 1 to n.Then function will return the sum.

Output:

Enter a number:10

Sum of first 10 integer from 1 to 10 is:55

You might be interested in
The implementation stage of the SDLC _____.
Karolina [17]

Answer:

d. involves analyzing end-user business requirements in order to refine project goals

Explanation:

In the software development life cycle, the implementation stage is the stage where the computer programmers begin the actual coding of the application required by the end-user. At this stage, the developer takes into account the needs and specifications of the customer.

For example, if the end-user wants a software application that can track payment records, the researcher at this stage begins using the right software to code programs that can effect this function.

6 0
3 years ago
As important as it is to plan ahead, sometimes you_____.
timama [110]

Answer:

B. Can't stop things from doing wrong.

Explanation:

Life is never for certain there are so many unpredictable things that can happen like at one moment you are turning onto the street and you get into a car accident you didn't plan for that to happen. Anything can happen on a day to day basis that's why something can go wrong and all your plans won't work anymore.

4 0
3 years ago
Read 2 more answers
A circuit contains two 500 OHM resistors connected in parallel and is supplied with 60 VDC. What is the current in the circuit?
andreyandreev [35.5K]
Remember Ohm's law V=IR. Plugging in the information gives you 60=500\times I \\ \implies I=0.12 amperes of current.
5 0
3 years ago
Read 2 more answers
What is the argument in this function =AVERAGE(F3:F26)
monitta
The argument for the function would be answer "D".
5 0
3 years ago
In cell D5, enter a formula to calculate the number of days for the first workshop. Add 1 to the results to include the total nu
iris [78.8K]

Answer:

D7

Explanation:

5 0
3 years ago
Other questions:
  • What is the operating system?
    9·1 answer
  • Consider the classes below: public class TestA { public static void main(String[] args) { int x = 2; int y = 20 int counter = 0;
    8·1 answer
  • Which option should you select to ignore all tracked changes in a document? To ignore all tracked changes in a document, you sho
    15·2 answers
  • What does RFID use for wireless communication?<br> Infrared<br> IoT<br> Smart chip<br> Tag
    14·1 answer
  • Brake fluid should be checked __________.
    8·2 answers
  • Which media device uses the characteristic continuous?
    10·1 answer
  • Different between input and output device​
    5·1 answer
  • What is technology in computer​
    6·1 answer
  • The first page of a website is what?​
    5·2 answers
  • after entering backstage view, and clicking account settings, what are the steps for creating a delegate for an outlook folder
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!