Question #22178

write a program using c++ to find the sum of arithmetic progression below. 6,10,14,18,20

Expert's answer

#include <iostream>
int main()
{
int a[] ={6,10,14,18,20};
int n=5; //number of elements in a
int sum = 0;
for(int i=0; i<n;i++)
{
sum +=a[i];
}
std::cout<< "The sum of progression is " << sum <<
"
";
return 0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS