Then to develop a program which process and show the terms of a progression, written in C + +, use the following code:
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
int numberterms;
float firstterm, ratio;
cout << "Insert the first term of the progression: ";
cin >> firstterm;
cout << "Insert the reason of this: ";
cin >> ratio;
cout << "Insert the number of terms to display: ";
cin >> numberterms;
for (int r = 1; r <= numberterms; r++)
{
cout << firstterm;
firstterm = firstterm*ratio;
if (r != numberterms)
cout << " ";
if (r == numberterms)
cout << endl << endl;
}
}
Respect to the indicated in the code, first we ask what is the first term of the sequence, then the ratio (it can be also decimal or fractional) and finally, the number of terms of the succession to be displayed.

Help


