Write a c program that reads arbitrary number of integers Th
Write a c++ program that reads arbitrary number of integers. The program calculates a summation series based on these numbers. The sign of each term of the series alternative between positive and negative; the first term in the series is positive. The following rules are used to calculate the term from the number read. If the integer read is zero or negative then term = number*10 Otherwise, if the number is less than 5 then term = number * 5 Otherwise, terms = number.
Solution
#include <iostream>
using namespace std;
int main()
{
int a[100],values,count,summation;
cout << \"enter number of terms in the series max 100 : \";
cin>>values;
count=1;
cout << \"enter terms in the series\";
while (count<=values)
{
cin>>a[count];
if (a[count]<=0)
{
a[count]=a[count]*10;
}
else if (a[count]>0 && a[count]<5)
{
a[count]=a[count]*5;
}
if ((count)%2==0)
a[count]=-a[count];
summation=summation+a[count];
count++;
}
cout<< \"total sum : \"<< summation <<endl;
return 0;
}
