Write a program to display the summation of the following series :
12+ 32+52+72+92+112+132 +152
#include <iostream>
using namespace std;
int main()
{
int sum=0;
for(int i=12;i<=152;i+=20){
sum+=i;
if (i==152)
cout<<i<<" = ";
else
cout<<i<<" + ";
}
cout<<sum;
return 0;
}
Comments
Leave a comment