In this article you will get C++ program to print series 1 -4 7 -10 . . . . -40.
Program
#include<iostream>
using namespace std;
int main()
{
int i,a=-1,b;
for(i=1;i<=40;i+=3)
{
a*=-1;
b=i;
b*=a;
cout<<b<<" ";
}
return 0;
}
In this article you will get C++ program to print series 1 -4 7 -10 . . . . -40.
Program
#include<iostream>
using namespace std;
int main()
{
int i,a=-1,b;
for(i=1;i<=40;i+=3)
{
a*=-1;
b=i;
b*=a;
cout<<b<<" ";
}
return 0;
}