I dont really have time to read all the material in the text. Ive been skimming it. |
|
|
The good news is that I can see from your posts that you're pretty smart and you're picking it up quickly with Andy's help. Going forward, I urge you to read the material carefully. This isn't like a literature class where you can fake your way though it. It's more like football where if you don't practice, you're going to get killed on the field. |
|
|
|
|
|
|
|
|
|
|
sum -= findLowest(list, n);
and line 10 could be n--;
for the short way of doing this.return sum / static_cast<double>(n);
. The "static_cast" is the more up to date usage. This maybe ahead of where you are at but something to think about. http://www.cplusplus.com/doc/tutorial/typecasting/#implicit_in_classes and http://www.cplusplus.com/doc/tutorial/typecasting/#static_cast .
|
|
|
|
foo.cxx:14:1: warning: control reaches end of non-void function [-Wreturn-type] |
if
statement. If the if condition isn't true, then no return statement executes. That points to the bug: the return statement is in the wrong place. You'll also get a warning that variable min is never used. Finally, you need Andy's point about casting the sum to a double. So the result should be :
|
|
What that means is that you can run off the end of the function without returning a value. That's always bad. Looking at the code, you can see that the only return statement is inside the if statement. If the if condition isn't true, then no return statement executes. That points to the bug: the return statement is in the wrong place. You'll also get a warning that variable min is never used. Finally, you need Andy's point about casting the sum to a double. So the result should be : |
|
|
for (char lco = 'A', ss = 0; lco < 'G'; lco++, ss++)
where "lco" is my shorthand for Loop Counter and here "ss" is short for "sub script". Although "ss" is most often seen used with stringstreams. As you can see "lco" can be defined as any type you need. And yes, even-though "ss" is defined as a char it still works. You could even define "ss" outside of the for loop an increase "ss" inside the outer for loop and it will work the same.for (int lci = 0; lci < aCounters[ss]; lci++)
.
|
|
All I have left to work on before I work on my main function |
|
|
Pls enter number of scores: 8 No. of scores: 8 Score no: 0 7 Score no: 1 49 Score no: 2 73 Score no: 3 58 Score no: 4 30 Score no: 5 72 Score no: 6 44 Score no: 7 78 Program ended with exit code: 0 |
for (char lco = 'A', ss = 0; lco < 'G'; lco++, ss++)
looks kind of confusing to me. Is there an easier way to format the histogram so i could read it easier? I know I'll need a couple nested loops.. I'm just not sure what you mean.
|
|
error: invalid operands of types 'int()' and '<unresolved overloaded function type>' to binary 'operator<<'
|
|
|
|
error: expected primary-expression before ']' token
for both
cout << list[i] = generateOneScore << endl;
|
|
You are combining two things. You need to 1) generate the score, place it in the list and then 2) separately print it out. |
|
|
|
|
|
|
|
|