Using four step development method design write compile and
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:
Solution
#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;
}
