In: Computer Science
1. Write a program in C++ that takes as inputs a positive integer n and a positive double a. The function should compute the geometric sum with base a up to the powern and stores the result as a protected variable. That is, the sum is: 1 + ? + ? ^2 + ? ^3 + ? ^4 + ⋯ + ? ^?
2. Write a program in C++ that takes as input a positive integer n and computes the following productsum mix: 1 * (1+2) * (1+2+3) * (1+2+3+4)*…*(1+2+3+…+n) and stores the result as a protected variable.
#include#include using namespace std; int main() { float a, n, i, term, sum; cout << "Enter a: "; cin >> a; cout << "Enter n: "; cin >> n; if (n > 0) { term = a; sum = 1; for (i = 1; i < n; i++) { sum += term; term = term + a; } cout << "Sum of geometric series: " << sum << endl; } system("pause"); return 0; } ================================= #include #include using namespace std; int main() { float a, n, i, term, p; cout << "Enter a: "; cin >> a; cout << "Enter n: "; cin >> n; if (n > 0) { term = 1; p = 1; for (i = 2; i < n; i++) { p *= term; term = term + i; } cout << "Product: " << p << endl; } system("pause"); return 0; }