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
Mnenie [13.5K]
3 years ago
11

For this lab, youhave to write a programnamedseriesFunction.cthat prompts user to enter two values, x and n. Then it would use a

function to compute the sum of the series. It will take two arguments, x and n. It will return the sum of the series.

Computers and Technology
1 answer:
Komok [63]3 years ago
4 0

The question is incomplete! Here is the complete question and it’s answer!

Question:

For this lab, you have to write a programnamedseriesFunction.cthat prompts user to enter two values, x and n. Then it would use a function to compute the sum of the series. It will take two arguments, x and n. It will return the sum of the series.

S(x) = x + (x+1) + (x+2) + (x+3) + (x+4) +........................+(x + n - 1) + (x + n)

As an example, for input values x = 100 and n = 0, it should output 100. For x = 100 and n = 1, it should output 100 + 101 = 201.

Step by Step Explanation:

We are required to find the sum of the following series.

S(x) = x + (x+1) + (x+2) + (x+3) + (x+4) +........................+(x + n - 1) + (x + n)

We have created a function seriesFunction which takes two inputs x and n and calculates the sum of the series (x+n). A for loop is used to run n times and a sum variable is used to keep adding n number of times.

Then we have driver code in the main function where we ask the user to enter x and n values and then called the seriesFunction to calculate the sum of series

Code:

#include <iostream>

using namespace std;

 int seriesFunction(int x, int n)

 {

     int sum;

     for(int i = 0; i <= n; i++)

     sum = sum + (x+i);

     cout<<"sum of series: "<<sum<<endl;

 }

int main()

{

   int x,n;

   cout << "Enter x"<<endl;

   cin >> x;

   cout << "Enter n"<<endl;

   cin >> n;

   seriesFunction(x,n);

   return 0;

}

Output:

Test 1:

Enter x

100

Enter n

1

sum of series: 201

Test 2:

Enter x

100

Enter n

4

sum of series: 510

You might be interested in
Which set of steps will organize the data to only show foods with more than 100 calories and rank their sugar content from great
WITCHER [35]

Here are the multiple choices below:

A. Sort sugar in descending order, and filter Calories by under 100 calories.

B. Sort sugar in ascending order, and filter Calories by over 100 calories.

C. Filter Calories by over 100 calories, and sort Sugar in descending order.  

D. Filter Calories by over 100 calories, and sort Sugar in ascending order.

Sorting and Filtering in Excel or Access are two tools that let you organize and view your data. Sorting your data puts it in order and filtering lets you hide unimportant data. And in this case, it is no different. If you want to show foods with more than 100 calories, you should filter calories by over 100 and sort sugar in highest to the lowest (descending order).


7 0
4 years ago
After unit and integration testing are completed, _________ testing ensures that all hardware and software components work toget
raketka [301]
Testing ensures that all hardware and software components work together
5 0
3 years ago
Which of the following have the smallest file size
Alla [95]

Answer:

A.

Explanation:

Ebooks are typically only text, which is smal.

However, a Photo can be very small too, so the answer is not definitive.

3 0
3 years ago
Which of the following commands would I use to begin a new presentation?
ki77a [65]

Answer:

begin >new

Explanation:

just trust me ok hehe

7 0
4 years ago
Default tab stops are set in word every _______ inch. a. ¾ b. ½ c. 1 d. ¼
Dennis_Churaev [7]
A) 3/4 inch Meow! XD
6 0
3 years ago
Other questions:
  • A data structure used to bind an authenticated individual to a public key is the definition of ________.
    14·1 answer
  • When creating wireframe geometry and the autocursor is on what happens when you push the shift key?
    13·1 answer
  • Most smartphones use operating systems developed by ________.
    10·1 answer
  • How long is the latency time of a typical hard-disk drive spinning at 360 revolutions per second?
    6·1 answer
  • Why is personal responsibility important when considering technology?​
    14·2 answers
  • If you want a user to actively participate in an online activity, create a web ______________.
    12·2 answers
  • Discuss the importance of top management commitment and the development of standards for successful project management. Provide
    10·1 answer
  • What are folders within folders called​
    8·2 answers
  • NO LINKS<br> Do you need to pay monthly to stream on Twitch?
    5·1 answer
  • Monica is writing a paper, and it needs to contain a certain amount of words. What Word Online feature can she use?IndentingProo
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!