Write C++ Program to Print following series: 1 -4 7 -10……….-40
#include
#include
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;
}
The Way to Programming
Write C++ Program to Print following series: 1 -4 7 -10……….-40
#include
#include
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;
}