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
Can someone help me to give this guy brainliest the button is not there
slamgirl [31]

Answer:

hmm maybe try to reload the page

Explanation:

8 0
3 years ago
Which operating system is used by most desktop and laptop computers?
OleMash [197]
Right know, probably Windows 7. Linux is not really used for home use and there are not many people on mac. On Windows, the most popular is still Windows 7 because XP and Vista are dead and the servers, scrap them. Then windows 8 is not great and Windows 10 is not the best for work computers so most desktops and laptops are still running Windows 7.
6 0
4 years ago
Your new home has a vacuum system. what kind of computer is controlling it?
Scrat [10]
The answer is embedded computer. It is a PC framework with a committed capacity inside a bigger mechanical or electrical framework, frequently with ongoing figuring constraints. It is implanted as a component of a total gadget regularly including equipment and mechanical parts. Installed frameworks control numerous gadgets in like manner utilize today.
6 0
4 years ago
Sentiment analysis algorithms use simple terms to express sentiment about a product or service, so ________ makes it __________
Anna35 [415]

Answer:

sarcasm , difficult

Explanation:

Sarcasm make it difficult to classify online content as positive ,negative or neutral because sarcasm content had many meaning and it involve some humor also which make it difficult weather to classify as positive or negative or neutral.

5 0
3 years ago
Given the function definition below, what is the effect of thecall:
Romashka-Z-Leto [24]

Answer:

Hi!

The correct answer is E.

Explanation:

void change(int ar[], int low, inthigh)  {  

 int temp;

 if(low< high)  {  <em>// here ask if the positions low and high of the array are the same.</em>

  temp= ar[low];  <em>// first, saves the element on ar[low] in temp.</em>

  ar[low]= ar[high];  <em>// second, the element on ar[high] in ar[low]. First switch.</em>

  ar[high]= temp;  <em>// third, saves the element on temp in ar[high]. Complete switch.</em>

  change(ar,low + 1, high - 1);  <em>// Recursive call, adding one position to low, and subtracting one position to high. </em><em>Important: </em><em>When low and high have the same value, the recursive call will finish.</em>

}

}

Result: Switch the lower half of elements in the array with the upper half.

8 0
3 years ago
Read 2 more answers
Other questions:
  • Need Help ASAP!
    14·2 answers
  • Hey how are yall today?
    12·2 answers
  • Varied amount of input data Statistics are often calculated with varying amounts of input data. Write a program that takes any n
    8·1 answer
  • A potentiometer a three wire variable resistor is used in which type of sensor ?
    13·1 answer
  • How to unsubscribe from Brainly
    6·2 answers
  • I need help with the last question pleasee help me guys .
    11·2 answers
  • when you enter a url, you’re creating a(n) ____ link, which is the full and complete address for the target document on the web.
    9·1 answer
  • PLEASE HELP URGENT!!
    5·2 answers
  • Digital rights include the right to
    12·1 answer
  • When creating an html document, what do we use to set aside space for content?.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!