Unknown error in the code.

This code is giving the error:

Pl.cpp:39:7: error: non-ASCII characters are not allowed outside of literals and identifiers
cout<<‘enter l : ‘
Pl.cpp:39:10: error: use of undeclared identifier 'enter'
cout<<‘enter l : ‘
^
same for all cout.
I am using text editor in Yosemite.

#include<iostream>
#include<cmath>
using namespace std;

int factorial(int n)
{
int f = 1;

for (int i = n; i > 0; i--)
{
f = f * i;
}

return f;
}

float Pl1(int a, int b, float c)
{
float d,e;
if (a-b==1||a==b)

{

e=factorial(2*b -1)*pow((1 - pow(c,2)),b/2);
return e;

}

d = c*(2*a - 1)*Pl1(a-1, b, c) + (a + b - 1)*Pl1(a-2, b, c);
return d;

}


int main()
{
int l,m;
float theta,P,Y;
cout<<“enter l :”
cin >> l;
cout << “ enter m : ”
cin >> m;
cout << “ enter theta : ”;
cin >> theta;

P = Pl1(l,m,theta);
cout<<“Value of legendre polynomial is : ” <<P;

Y = pow(-1,m) * (pow(((2*l + 1)*factorial(l - m))/(4*3.14*factorial(l+m)) , 1/2)) * P * cos(theta);
cout<<“Value of Y is : ”<<Y;

}




1
2
3
cout<<“enter l :”
//    ↑         ↑
//What are those? 
String literals are encased in double quotes " , not in any other character.
I am a beginner. can you tell me how to correct this.
Replace those non-ascii characters with double quotes.
Like:
1
2
3
cout<<"enter l :"
//    ↑         ↑
//Note: proper quotes 
I'm guessing you did copy & paste with this. If so, you didn't get pure text in your copy & paste operation, you've got some non ascii characters in there. What looks like double quotes - " - may not actually be. If you really can't tell the difference (perhaps your editor's fault), then delete those lines with the problem, and type them in manually yourself.
Topic archived. No new replies allowed.