Why am I getting the 'expected expression' error?
Hi,
I'm writing a program in Xcode about Fibonacci Series. When I use the for statement, I keep getting the error "expected expression" and the small arrow points to the 'for' in my code. Here is my code:
#include <iostream>
usingnamespacestd;
int main()
{
int n, firstTerm = 1, secondTerm = 1, nextTerm;
cout<<"Enter the number of terms: ";
cin>>n;
cout <<"Fibonacci Series: " << firstTerm << " + " << secondTerm <<
for (int i = 1; i <= n-2; ++i) { //This line is where I'm getting the error. It looks correct to me.
nextTerm = firstTerm + secondTerm;
cout<<nextTerm<<" + ";
firstTerm = secondTerm;
secondTerm = nextTerm;
}
return 0;
}