Hot answers tagged

2

The error you are getting is not saying that you are passing a double instead of a float, but that a double is expected. You are passing average, which is not a variable but a function. Your prototype declaration for the function (float average (void)) is also throwing an error because it does not match the function, which need has a definition of float ...


1

ranks[] means an array of values that has been named ranks; from the declaration, we can tell that the values will all be integers. Any time you see a name followed by square brackets in C-based languages (C, C++, Java, etc.), you know that you are dealing with an array. If you have an integer or integer variable (such as i) in the square brackets, then you ...


1

When the int array scores is declared here int scores[n]; it will have n elements, indexed to 0. When 3 is entered, the elements of scores are scores[0], scores[1] and scores[2]. There is no scores[3]. (Notice the loop executes until i < n to ensure it will be within bounds). This line scores[n] = get_int("Score %i: ", i + 1); will try to ...


Only top voted, non community-wiki answers of a minimum length are eligible