Sunday, 9 October 2016

To print series 1,-4,7.....

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int x=-1,y=1,i;
cout<<"Enter the no. of terms you want to print ";
cin>>i;
for (int z=0;z<=i;z++)
{
   z=x+y;
   cout<<z<<"\n";
   x=y;
   y=z;
}
getch();
}

No comments:

Post a Comment