Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

programming language 17 // Lab 4 / Descriptiont Write a program that will find the sum of a arithmic series given the first term, its

programming language

image text in transcribed

17 // Lab 4 / Descriptiont Write a program that will find the sum of a arithmic series given the first term, its difference and the number of terms in the series. // 1. Declare the needed variables // 2. Collect the user input (a - first term, d-difference, n-number of terms // 3. Find the sum (Using a loop) 17 4. Find the sum (Using the formula below) // 4. Print BOTH sums, they should match!!! 1/ Note: For example, if a = 1, d - 3, n - 4 then the series is: 1 + 4 + 7 + 10 and the sum - 22 // if a - 8, d. -5, n = 5 then the series is 8 + 3 + (-2) + (-7) + (-12) and the sum - -10 Sum - n + (2. a + (n-1).d) / 2; . . . . . . #include using namespace std; // Header file needed for I/O ine used for simplicity int main() // 1. Declare the variables needed for this program. 11 Use a, d, n and sum as integers // You may declare other variables as needed int a, d, n; int suml - 0; // Sum from the loop int sumF = 0; // Sum from the formula 1/ 2. Collect the user input needed cout > a: cout > d; cout >n; 1/ 3. Once the input is entered, use a loop to find the sun // 4. Find the sum using the formula 15. After the sum is calcualted find the su cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions