Skip to main content
2 votes

PSET 1 CASH stuck!

It looks you have written the body of various functions in the main() itself after function calls. These should go into the respective function definitions, generally places after the closing bracket ...
devinder's user avatar
2 votes
Accepted

pset1 water task, function code ignored

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. ;-)
Cliff B's user avatar
  • 69k
1 vote

Use of bool in PSET2

Your use of bool is correct, subject to the real problem. The function call isn't. I think your mind just got stuck using a pattern though. Look at the following code: // Make sure every character ...
Cliff B's user avatar
  • 69k
1 vote
Accepted

Function in C: How to create

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 ...
Cliff B's user avatar
  • 69k
1 vote

Passing arrays into function in tideman

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 ...
Robert S. Pratt's user avatar
1 vote
Accepted

Week 2 Lecture - Functions - Valid Triangle

Just like the function printf, the valid_triangle function has to be called from within main in order to execute and produce results.
DinoCoderSaurus's user avatar
1 vote

Pset 3 runoff. Votes not updating, trying to understand the code sequencing

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 ...
smitha's user avatar
  • 13
1 vote
Accepted

CS50_Web ORMs,APIs_ lecture 4, classes4.py - Understanding Classes, Objects, Functions and Lists

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 ...
DinoCoderSaurus's user avatar
1 vote
Accepted

Adding a code block to perform operations on float

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 } ...
Blauelf's user avatar
  • 21k
1 vote
Accepted

Trying to use functions to modify pset2 Caesar characters, get error: expression result unused for each function

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 ...
curiouskiwi's user avatar
  • 18.7k
1 vote
Accepted

Pset3 Find - error in "helper" file - 'expected expression'

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 ...
Blauelf's user avatar
  • 21k
1 vote

C : error non-void function search - value (find)

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,...
Cliff B's user avatar
  • 69k
1 vote
Accepted

strstr function not working

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 ...
DinoCoderSaurus's user avatar
1 vote

This code of triangle problem always give me "true".I can,t find bug in this please find the bug

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, (...
Cliff B's user avatar
  • 69k

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