"expected ';' before string constant error"

Hi,
I have this error and I don't know why, please help me. Thank you... ( I have to calculate the result of 3 different operations in the same program)

________________________________________________________________________________
#include <iostream>

using namespace std;

int main()
{
int x=0;
float d=0.005;
int i=0;
int p1[x];
int p2[x];
int p3[x];

for (i=0;i<=20;i*d);
{
p1[x]=x+i;

p2[x]=(3*(x+i*x+i)-1)/2;

p3[x]=((5*(x+i*x+i))-3*x+i)/2;

}
cout"p1[x]= "<<p1[x]<<"\n";
cout"p2[x]= "<<p2[x]<<"\n";
cout"p3[x]= "<<p3[x]<<"\n";

return 0;

}
______________________________
your missing << after cout eg. cout <<

for (i=0;i<=20;i*d); you probably don't want the ; after the for loop. Also, I don't know what i * d is supposed to do but its wrong.
Thank you Yanson :)
Also, I'm not sure what the arrays int p1[x] are for. In C++ an array must have a fixed size, but x is a variable. Not only that, but it has a value of zero. An array with no elements is not valid. Maybe you don't actually need an array?

However, it isn't clear what it is you are trying to do. x is used a lot in the calculation, but its value is always zero, so it doesn't do very much.

As already mentioned the for loop has errors.
You are right, it is i+0.05 but now the program does not do anything, the black screen stays empty ( codeblocks). Please help me.
Since i is an integer, adding 0.05 to it will leave it unchanged. (another cause of an infinite loop).

You could try this:
 
    for (float i=0; i<=20; i += d)


.. but there are still other issues to resolve.
Topic archived. No new replies allowed.