I'm recieving this error on the line where my first bracket is, before the main portion of the code. The program is supposed to solve the simple formula, print x and y and three different descriptors based on their value.
'm really new at this and if you could even point me in the right direction, that would be helpful.
The error occurs after int main();
I have tried a number of things, including removing the ; from int main(); , but nothing seems to change the error (some make it worse)
Thank you for any help in advance, suggestions or prodding should be enough.
#include <iostream>
#include <math.h>
using namespace std;
int main();
{
double x;
double y;
cout << "my name\n This is the output of my first program" << endl;
cout << "x" << '\t' << "y" << endl;
for(x=-4.0, x=2.0, x=x+1)
{
y=((15*(x*x*x)-4*x+54)/((sqrt(5*X*X+1)+(7*abs(x-2.5)))
cout << x << '\t' << y;
if(y=0)
cout << "Y IS ZERO";
if(y>0)
cout << "Y IS POSITIVE";
if(y<0)
cout << "Y IS NEGATIVE";
cout << endl;
}
cout << "My first program is complete" << endl;
return 0;
I have tried a number of things, including removing the ; from int main(); , but nothing seems to change the error (some make it worse)
The semi-colon should definitely not be there. You should remove it and handle whatever other errors there are. If you encounter other compiler errors, please post them here.
Also,
for(x=-4.0, x=2.0, x=x+1)
the x=2.0 will always evaluate to true so you will have an infinite loop. You should use a double equals sign == here. While on the subject, you shouldn't be doing exact equality with doubles anyway. You should make x an int. Also, your for loop is malformed. There should be semi-colons instead of commas.
if(y=0)
There should be a double equals sign here as well.
1 2
= <-- This is the assignment operator
== <-- This is the equality operator