Void functions

Hi, guys. I hope you can help me. I just do not get what is wrong with my dev c++ program
using namespace std;
void locate(int&, int&, int );
int main()
{ int N, more, less;

{ cout<<"Enter a value for N: ";
while (N>10 || N<0);
locate(more, less, N);


void locate(int& more, int& less, int N)

double x;
int n=0;
ifstream indata("testdata.txt");
{if (x>0.7)
if (x<0.6)
} while(n, n<=10, n++);

I'm supposed to do the following:
Problem 2.57:
Write a C++ program which consists of a main function and a void function called locate ( int N, int& more, int& less).
The main function :
a. Reads from the keyboard a value for N ( between 1 and 10).
b. Calls the function locate.
c. Outputs to the screen the values of "more" and "less" with appropriate labels.
d. Outputs to the screen (lableled) the quotient of more divided by N, as a percentage.
The function locate reads 10 data values from a text file "testdata.txt", found by clicking here, then calculates and returns an integer "more", which is the number of entries read from the text file that are greater than 0.7, and an integer "less", which is the number of entries read from the text file that are less than 0.6.
0.351 0.659 0.901 0.136 0.432
0.835 0.547 0.470 0.211 0.965

What is the error?
your first problem is that you tell compiler to use namespace std before it is declared. put that line after all the includes.

another problem is that you never define more and less, so they are equal to some rubbish value.
also your (more/N)*100 may equal 0 often, becouse more is int and N is int and when you divide integers the result is also integer. you may want to write something like more/(float)N*100 instead.

the last thing:
if (x>0.7)
if (x<0.6)

you don't need to use curly brackets if you only have one statement after if and if you use them then you don't need a semicolon.

hope this helps
For future posts, please post snippets of code in the "code" brackets like so:
code code code, more code, a lot more code

I don't know a lot about C++ (yet) but you need to work on your neatness, such as putting spaces between your opperators for instance the << and >> opperators.
You do realize this is a month-old thread, and that the guy hasn't posted anything since.
Haha, i think he got the answer and forgot to give thanks to someone in here.

Or maybe he forgot to open this forum again .. haha
Topic archived. No new replies allowed.