Question: in c++ You must implement the function: string get_ap_terms(int a, int d, size_t n); which returns a string containing the first n terms of the

in c++

You must implement the function: string get_ap_terms(int a, int d, size_t n);

which returns a string containing the first n terms of the arithmetic progression (AP) as a sequence of comma-separated values.

Recall that an AP is specified by two terms a and d. The first term is a, and the d is how much you add to each term to get the next term. So the first N terms of the above AP will be:

a, a+d, a+2d, . . . , a+(n-1)*d

Suppose, for example, that a = 1, d = 3, and n = 5. Then this function should return the string

"1,4,7,10,13"

// Return a string of the form n1,n2,n3,... for the given AP. string get_ap_terms (int a, int d, size_t n) {

// TODO - Your code here

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!