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

Using four step development method, design, write, compile, and run a C++ progra

ID: 3923672 • Letter: U

Question

Using four step development method, design, write, compile, and run a C++ program to calculate the sum of the even integers from 1 to 50. Here is the formula for calculating such a sum for an arithmetic progression series: sum = (5) [2a + (n-1)d]. n is the number of integers to be added, a is the first number in the series d is the difference between each number. Make sure that the division by 2 in the formula is implemented properly in your program. SOLUTION: Step 1-Analyze the Problem [5 points] There are three nput tthe pograma n d. Data types: There is only one output from the program, namely, sum. Data type:

Explanation / Answer

#include <iostream>

using namespace std;

double sumOfEvenIntegers(int a, int n, int d);

int main(){
cout<<sumOfEvenIntegers(2,5,2);
}

double sumOfEvenIntegers(int a, int n, int d)
{
int temp = (2*a) + ((n - 1)*d);
double sum = (n/2.0)*temp;
return sum;
}

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