Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A sequence of integers such as 1, 3, 5, 7, ... can be represented by a function

ID: 3534418 • Letter: A

Question

A sequence of integers such as 1, 3, 5, 7, ... can be represented by a function that takes a nonnegative integer as paramater and returns the corresponding term of the sequence. For example, the sequence of odd numbers can be represented by the function

    

     int odd(int k) {return 2 * k + 1;}

Write an abstract class AbstractSeq that has a pure virtual member function

   virtual int fun(int k) = 0;

as a stand-in for an actualsequence, and two member functions

    void printSeq(int k, int m);

    int sumSeq(int k, int m)

that are passed two integer paramaters k and m, where k < m. The function printSeq will print all the terms fun(k) through fun(m) of the sequence, and likewise, the function sumSeq will return the sum of those terms. Demonstrate your AbstractSeq class by creating subclasses that you use to sum the terms of at least two different sequences. Determine what kind of output best shows off the operation of these classes, and write a program that produces that kind of output.

Explanation / Answer

no need to use conio. #include<iostream.h> should compile. it is the standard. One thing you can try is using #include<iostream> and u can try #include<stdio.h>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote