11/17/2015

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

Problem :- Write A C++ Program To Print The  Given Series 1 -4  7 -10 . . . . . -40

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 .

Try Yourself  Write A C++ Program To Find Sum Of Series 1+2+4+8+16+32+...........n

Solution :-

#include<iostream>
using namespace std;
int main()
{
//By-Ghanendra Yadav
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:-

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

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment