Question: write three programs in C++. Each of the programs will calculate the nth term of a sequence. The value for n is to be supplied
write three programs in C++. Each of the programs will calculate the nth term of a sequence. The value for n is to be supplied by the user. The term is defined by the following recurrence relation. S(1) = 3 S(n) = 3*S(n-1) The programs (1 - 3) are as follows (and it is three separate programs, not a single program with three separate functions): For all programs main will ask the user for the value of n, then For program 1 main will call a recursive function S to determine the value for the nth term. For program 2 main will use a for loop to determine the value for the nth term. For program 3 main will use a single arithmetic expression to determine the value for the nth term. Testing: Run each of these programs with values for n of 100, 1000, 100000, 1000000. If you can see no difference in the way the programs run (for example, the time or stack overflow), then run them for larger numbers.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
