Question: Programming Language: C++ PURPOSE: To understand how sequences and summations are manifested in coding. To store sequences in arrays. PROBLEM: You are to write a

 Programming Language: C++ PURPOSE: To understand how sequences and summations aremanifested in coding. To store sequences in arrays. PROBLEM: You are to

Programming Language: C++

PURPOSE: To understand how sequences and summations are manifested in coding. To store sequences in arrays. PROBLEM: You are to write a program that will determine the values in either arithmetic progression or geometric progression sequence given an upper limit. You will also compute the sum of the values in the sequence given a lower and an upper limit. METHOD: You will need to declare an array of 41 values (ignore the value indexed by O). You should have functions to generate an arithmetic progression, a geometric progression, sum values, print the sequence and the sum, and open the files. INPUT: The input contains several test cases. Each test case is composed of a single line, containing a letter (either 'A' or 'G', for arithmetic or geometric progression, respectively). Following the letter, there is a value for a, then a value for d or r, then the number of terms (N) to compute in the sequence, where 1 SNS 40. The line ends with the lower limit (L) and upper limit (U) needed for the summation, where (1 SL, US 40). The end of the input is indicated by the end of the file. You can read one line of input in a function. Input file: SeqSum.dat MAKE SURE YOU MAKE UP ONE OTHER INPUT FILE! Sample input file: A 3 5 A 2 1 G 2 3 G2 -2 A 4 4 20 25 25 20 10 1 5 1 10 2 20 25 15 15 8 OUTPUT: Your name as first line of output. Sample corresponding output: 23 83 Arithmetic sequence: 3 8 13 18 53 5863 68 73 78 Sum of sequence from 1 to 20 term is 1010 28 88 33 38 9398 43 48 OUTPUT: Your name as first line of output. Sample corresponding output: 23 28 38 43 48 Arithmetic sequence: 3 8 13 18 53 58 63 68 73 78 Sum of sequence from 1 to 20 term is 1010 7 10 11 18 19 20 21 Arithmetic sequence: 2 3 4 5 12 13 14 15 16 17 22 23 24 25 26 Sum of sequence from 5 to 25 term is 336 162 486 1458 4374 13122 39366 Geometric sequence: 2 6 18 5 4 Sum of sequence from 1 to 5 term is 242 Geometric sequence: 2 - 4 S -16 32 -64 128 2048 -4096 8192 -16384 32768 -65536 131072-262144 Sum of sequence from 10 to 15 term is 21504 -256 512 -1024 524288 -1048576 20 24 28 32 36 40 Arithmetic sequence: 4 8 12 16 Sum of sequence from 2 to 8 term is 140

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!