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
Windows server 2012 r2 includes hyper-v in which edition(s)?
SashulF [63]
<span>The Standard and Datacenter editions.</span>
7 0
4 years ago
I need an answer and fast What happens if a sequence is out of order?
horsena [70]

Answer:

i would say A

hope i helped <3

Explanation:

4 0
4 years ago
Read 2 more answers
13,Which hardware device is used in decoding the machine language version of an instruction in the Instruction Decode stage of t
Julli [10]
It should be the control unit
8 0
2 years ago
What's the biggest security issue with using social networking sites to market your listings?
Savatey [412]

The biggest security issue with using social networking sites to market your listings is Criminals may use social networking sites to identify your personal data.

<h3>What is a social marketing site?</h3>

A social marketing site is a site where people from around the world are connected in one place and share their thoughts and photos and other data.

The social sites are on the internet and there is a chance of stealing data and it identity theft, phishing, online predators, internet fraud, and other cybercriminal attacks are also some risks.

Thus, the largest security concern with using social networking sites to sell your listings is that thieves could use these sites to find personal information about you.

To learn more about social marketing sites, refer to the link:

brainly.com/question/15051868

#SPJ4

6 0
1 year ago
How can ICTs be used in the workplace to improve the way employees
nadezda [96]

Answer:

it allows them to work more efficiently, with fewer waisted resources

Explanation:

3 0
3 years ago
Other questions:
  • I need a idea of a origami for my coding class and it needs to be easy to make
    15·2 answers
  • Data is: a. Information endowed with relevance and purpose b. Set of specific objective facts or observations c. Some informatio
    10·1 answer
  • Jeremy, a college student, is preparing to give a speech on "Social Responsibilities." He refers to a Web page on a tab using
    10·1 answer
  • Marcus just created a new folder specifically for his buisness records so he would like to move last months business transaction
    13·2 answers
  • Explain how the principles underlying agile methods lead to accelerated development and deployment of software.
    6·1 answer
  • To remove an embedded chart, you should _____ it and press the DELETE key.
    14·2 answers
  • Write a statement that compares the values of score1 and score2 and takes the following actions. When score1 exceeds score2, the
    7·1 answer
  • Witch icon allows you to see paragraph formatting feature
    6·1 answer
  • Full form of http.<br>wrong answer will be reported ​
    6·2 answers
  • I need help NOW with my java script!! 1. What will the code below output to the console and why? const person = {
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!