Fibonacci series - a different way I am a C++ student (1.5 months into it). Please give feedback to this different way I have thought of for Fibonacci series. If there are any improvements needed, please suggest them also.

#include&lt;iostream&gt;
using namespace std;
void fibseries(long int n)
{
    double x=0;double y=1;
    for (long int i=1;i&lt;=n;i++)
     {
        if(i%2==1)
         {
            cout&lt;&lt;x&lt;&lt;" ";
            x=x+y;
         } 
        else 
         {
            cout&lt;&lt;y&lt;&lt;" ";
            y=x+y;
         }
     }
}
main()
{
    long int n=0;
    cout&lt;&lt;"The number of terms ";
    cin&gt;&gt;n;
    fibseries(n);
    return 0;
}
You should change this double x=0;double y=1; add newline after first ;
Using ++i is a best practice no matter if the type is int, so use ++i instead i++ and learn difference between them.
change main to int main, It is required to be standard compliant.
Why do you use doubles as x and y. Fibonacci numbers are always integers.
There are many fibonacci algorithms, you can look here 


https://stackoverflow.com/questions/14661633/finding-out-nth-fibonacci-number-for-very-large-n

http://fusharblog.com/solving-linear-recurrence-for-programming-contest/