I am trying to rebuild my code for my final project due in 2 hours... I am getting a stray \147 and 148 error, along with various other errors. What am I doing wrong???? I am not very good at this C++ stuff, so any help would be appreciated :) Please see program below:

int main ();

float amount = 0;
cout << 'enter the amount:' << endl;
cin >> amount;

float JT [amount];
{    
for (n=0 ; n<10 ; n++) // loop which inputs array data and calculate its sum

cout << “Enter number” << endl;// request for user input
cin >> JT[n];
}
float avg = 0;
float temp = 0;
{
for (int n = 0; n<amount; n++) //adds up the values in the array and store that value 
temp += JT[n];
}

avg = average (temp, amount);
cout << “The average age for the IT department is: “ << avg << endl;

return 0;
}

Please enter code in like this so it's easier for us to read.

This is wrong:

int main ();   // You need brackets for the block of code containing the main function. -not a semi-colon  ;

//like this

int main(){




return 0;
}

Saith,

Sorry about that- as I've said before, I'm not very good at this. I am also a newbie poster. So, please bear with me :)

int main ();{
 float amount = 0;
 cout << 'enter the amount:' << endl;
 cin >> amount;
float JT [amount];
{
 for (n=0 ; n<10 ; n++) // loop which inputs array data and calculate its sum
 cout << “Enter number” << endl;// request for user input
 cin >> JT[n];
}
 float avg = 0;
 float temp = 0;
{
 for (int n = 0; n<amount; n++) //adds up the values in the array and store that 15. value
 temp += JT[n];
}
 avg = average (temp, amount);
 cout << “The average age for the IT department is: “ << avg << endl;
return 0;
}

You still need to (at least) remove that first semi-colon.

Let me start by saying that this project seems awfully simple for a final C++ project. There are no data structures, objects, or pointers. I also don't see any includes or namespaces.

Remember, main() is a function. Do you place a semi-colon after the head of a function? No.
This:

int main();

should be this:

int main() { //notice no ';'

not this:

int main(); {  //note extraneous ';'

It also appears that you are trying to declare a dynamic array using a floating point value as the number of elements. It needs to be an integral value. Change "amount" to an int. Along those lines, and depending on your compiler, this may not be legal syntax. Compilers that comply with C++0x should allow you to declare an array in the manner you currently are, but older compilers generally don't allow it because "amount" is not a constant.

When you attempt to output a string, you need to use double-quotes, not single-quotes. This:

cout << 'enter the amount:' << endl;

should be this:

cout << "enter the amount:" << endl;

Use of braces around both of your for loops is incorrect. Have a look at this.

I know you're new, but everything that I see is a rookie mistake you should have learned to avoid as part of your class. Either you weren't paying attention in class or you're not paying attention to the code you're writing.

Also, please note, when posting code, use [code] ...code blocks... [/code]. All you have to do is click the " [code] " button in the tool bar, then place your code between the tags.
This:

[code] ...your code here... [/code]
produces this:

...your code here...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.