Answer to Question #172413 in Algorithms for JoshColl

Question #172413

 Design an algorithm and the corresponding flowchart for finding the sum of the numbers 2, 4, 6, 8, …, n


1
Expert's answer
2021-03-17T03:21:41-0400
#include<iostream>
using namespace std;
float sum(float a, float d, int n) {
   float sum = 0;
   for (int i=0;i<n;i++) {
      sum = sum + a;
      a = a + d;
   }
   return sum;
}
int main() {
   int n = 10;
   float a = 2, d = 2;
   cout<<"sum of series A.P is : "<<sum(a, d, n);
   return 0;
}

Algorithm:


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS