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]
4 years ago
6

Implement the function:

Computers and Technology
1 answer:
Sloan [31]4 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
Tech A states that modern vehicles use asbestos as the brake material. Tech B states that asbestos is no longer used in brakes.
Tanya [424]

Answer:

Tech A is correct.

Explanation:

The modern day vehicles have brakes system equipped with asbestos. It is a mineral which is a kind of fibrous crystal which enables the friction to stop the vehicle. The technician A specifies that the modern day automobiles use asbestos for their brake system.

4 0
3 years ago
Software for creating animations
Lady_Fox [76]
There´s PowToon, GoAnimate, ToonBoom. There are more, but these are the ones that I know about. I hope that I helped. Have a good day!

8 0
3 years ago
Read 2 more answers
What is the meaning of <br>computer<br>viruses ?​
Brut [27]

Answer:

Viruses are made from people all over the internet these days. they can be made from links you click on or things you download. Some are obvious some are not. gotta be careful on the internet these days!

Explanation:

7 0
3 years ago
Which attitudes are most common among successful IT professionals?
Bess [88]

Answer:

understanding the problem very well

writing documention to every piece of code you write

write clear and concise code

follow Industry accepted format for data storage

avoid recursion if possible

write modular code

5 0
3 years ago
Jackson builders is constructing new homes in the Parkway subdivision.The company needs the logic for an application that ncalls
lord [1]
<span>The calculatePrice() method can be written in C. It will use and return doubles (which allows for decimals). It will calculate the house price of $100K + $20K per bedroom and $30K per bathroom. Next it will take that price and append the sales percentage and return that value.
double calculatePrice(decimal numBedrooms, decimal numBathrooms, decimal salesPercentage)
{
decimal housePrice = 100000 + (20000 * numBedrooms) + (30000 * numBathrooms);
return housePrice + (housePrice * salesPercentage);
}</span>
8 0
4 years ago
Other questions:
  • Prompt the user for an automobile service. Each service type is composed of two strings. Output the user's input. (1 pt) Ex: Ent
    9·1 answer
  • Word Online works exact same as the downloaded Office 2016 version.<br>True<br>False​
    7·1 answer
  • Edhesive 4.1 question 1
    9·1 answer
  • How to solve 3(x - 2) = 9x<br><img src="https://tex.z-dn.net/?f=3%28x%20-%202%29%20%3D%209x" id="TexFormula1" title="3(x - 2) =
    14·1 answer
  • Children's Web sites may combine educational and entertaining information and activities with interactive advertising and direct
    5·2 answers
  • During which part of geologic time did photosynthesis evolve?
    15·2 answers
  • In which of the following work situations would word processing software be most appropriate to make the task easier?
    6·1 answer
  • Convert the following denary numbers into
    14·1 answer
  • Write a class Bug that models a bug moving along a horizontal line. The bug moves either to the right or left. Initially, the bu
    7·1 answer
  • Dgvdsgf cvdzgb fgvsdxchygfdrzvdszfgvsdzxd
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!