The structure is simple. Pay attention to placement of curly braces and semicolons, specifically, where they are NOT.
// The next line is a function signature to tell the compiler that
// the actual function will follow later. You either need a signature
// or the actual function to appear before it is ever used anywhere.
// note the ...
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 ...
One problem I see:
In tabulate() for(int i = 0; i > voter_count; i++) I think you meant to write
i < voter_count because otherwise it will not enter the loop since your condition will turn out to be 0 > 2
The same holds true for the next loop as well: for (int j = 0; j > candidate_count; j++). Here too, change j > candidate_count to j < ...
passengers is a list of Passenger objects, therefore print(self.passengers) is printing a list of Passenger objects. This print(self.passengers.flight_id) would fail because self.passengers is a list and the list has no flight_id attribute. Program needs to iterate through passengers list to get the attributes (e.g. flight_id, name) of each Passenger object.
So you decided to make some functions, why not. The function definition would be like
return_type function_name(param1_type param1_name, param2_type param2_name, ...)
// body of the function
// function apply_discount takes two parameters of type double
// and returns a double itself
double apply_discount(double price, double ...
It's exactly what it says. You have written an expression:
(character+key) % 26 + big_letters;
but you aren't setting the results of that expression to anything, hence it is unused.
You're doing the equivalent of saying
3 + 6
I'm guessing you actually want that function to calculate a new value and return it to main? If that's the case, then it can't ...
If you adjusted the indentation to match the curly braces, you'd realise that you put the else after the for loop, not one level higher after the if.
You don't need that outer if, as your for loop would do the same test. But it won't hurt either.
You have a logical problem inside your for loop, as you always return in the first iteration. Don't stop the ...
Having the errors multiply shouldn't necessarily be looked at as the code getting worse. Rather, the new errors should be analyzed for what they are. Sometimes an error masks other errors, other times, an error causes other errors. The reality here is that you have both conditions happening. First, the return issue is being detected by the compiler and ...
Are you sure the problem is with strstr? Did you use debug50 or gdb to make sure everything is as you expect? Did you read the man page on fgets? Of particular interest:
fgets() reads in at most one less than size characters from stream and stores them into the buffer pointed to by s.
Reading stops after an EOF or a newline. If a newline ...
This is a case where the code is doing exactly what is written, but maybe not what you want. Can you specify what it is supposed to be doing? I don't remember where this comes from in the course, (can you please state the source?) but the code appears to be doing what it is designed to do. If you test with any three numbers the following happens:
If any ...