Q:

C++ Program To Print The Series 1 -4 7 -10 . . . . . -40

0

Logic :-

 See the Series and according to series try to implement your logic .I just want to say only one thing if you practice more and more so you can solve and understood easily ,don't depend to copy paste answer .

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<iostream>
using namespace std;
int main()
{
 int i,a=-1,b,n;
 
 cout<<"Enter The Number of Terms\n";
 cin>>n;
 
 for(i=1;i<=n;i+=3)
 {
      a*=-1;
      b=i;
      b*=a;
      cout<<b<<" ";
 }
 return 0;
}

 

Output:

Enter The Number of Terms

40

1 -4 7 -10 13 -16 19 -22 25 -28 31 -34 37 -40 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Program To Print A Given Pattern Or Series Lik... >>
<< C++ Program To Print And Find Sum Of Series 1+2+4+...