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

Implement the function:

Computers and Technology
1 answer:
Sloan [31]3 years ago
3 0

Answer:

This is written in C++

Check comments for explanations

Program starts here

#include<iostream>

#include<string>

using namespace std;

//The function get_ap_terms begins here

string get_ap_terms(int a, int d, int size_tn)

{  

// This line initializes the expected string to empty string

string result = "";

//The for iteration loops through the number of terms the function is expected to return

for(int i = 1; i<= size_tn;i++)

{

//This line checks if the loop is less than the number of  terms    

if(i < size_tn)

  {

//This string gets the current term of the progression

   result+=to_string(a)+ ", ";

//This line calculates the next term

   a+=d;  

  }

  else

  {

//This line calculates the last term

   result+=to_string(a);

  }

}

//This line returns the string containing the first n terms of the arithmetic progression

return result;

}

//The main function starts here

int main()

{

//This line declares the first term (a), the common difference (d) and the number of terms (size_tn)

int a,d,size_tn;

//This line prompts the user for the first term

cout<<"First Term: ";

//This line gets the first term

cin>>a;

//This line prompts the user for the common difference

cout<<"Common Difference: ";

//This line gets the common difference

cin>>d;

//This line prompts the user for number of terms

cout<<"Number of Terms: ";

//This line gets the number of terms

cin>>size_tn;

//This line calls the function to print the string containing the first n terms

cout<<get_ap_terms(a, d, size_tn);

return 0;

}

//Program ends here

You might be interested in
Application software can run without the presence of system software true or false ​
sesenic [268]

Answer:

false

...........

.....

8 0
3 years ago
The different generation of computer explain in breif?​
Firlakuza [10]

You can download answer here

tinyurl.com/wpazsebu

7 0
3 years ago
Read 2 more answers
SOMEONE PLEASE HELP ME PLEASE HELP ME WITH THIS!!!!!
zavuch27 [327]

Answer:

The last one

Explanation:

I hope this is correct and have a great day

7 0
2 years ago
Read 2 more answers
Quick time and flash are two examples of what product
zheka24 [161]

there apps .........

8 0
2 years ago
To meet the requirement for the number of vdss on board, what must be true about pyrotechnic vdss?
asambeis [7]

Answer: They must be dated.

Explanation: If pyrotechnic VDSs are used, they must be dated. Expired VDSs may be carried on board, but a minimum of three unexpired VDSs must be carried in the vessel.

5 0
2 years ago
Other questions:
  • What is the protocol in the web search at the bottom?
    13·1 answer
  • Compare the logical link control and the media access control. Which of the following is a correct statement?
    7·2 answers
  • The code segmentif (speed &lt;= 40)cout &lt;&lt; "Too slow";if (speed &gt; 40 &amp;&amp; speed &lt;= 55)cout &lt;&lt; "Good spee
    11·1 answer
  • A 9-year old male castrated Westie presents on emergency after being rescued from a house fire. On presentation, the dog has a r
    9·1 answer
  • Write out the base sequence that is added directly after the primer. In order for Moodle to correctly grade this question, write
    11·1 answer
  • Which cable standard is a standard for newer digital cable, satellite, and cable modem connections?
    11·1 answer
  • Why computer literacy is vital to access in business work
    7·1 answer
  • Characteristics of RAM​
    5·1 answer
  • Anyone who do bug bounty hunt ?​
    10·1 answer
  • Fwee Pwoints Fwor You
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!