2

There's nothing wrong with the function. You just never call it from main. If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)


1

The structure is simple. Pay attention to placement of curly braces and semicolons, specifically, where they are NOT. #include statements // 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 ...


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

Just like the function printf, the valid_triangle function has to be called from within main in order to execute and produce results.


1

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 < ...


1

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. ...


1

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 } for example // function apply_discount takes two parameters of type double // and returns a double itself double apply_discount(double price, double ...


1

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 ...


1

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 ...


1

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 ...


1

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 ...


1

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 ...


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