Skip to main content
3 votes

Do - While loop

you want to keep asking the user about height if n is smaller than 1 or larger than 8 right ? check your code, the way you're writing it ,the program is gonna keep asking for height as long as n is ...
Mohamad Chaltaf's user avatar
2 votes
Accepted

Why is this while loop generating errors

Assuming the error you are getting is not related to a linking error, which is common, then the error I assume you are getting is loop_check.c:14:15: warning: '&&' within '||' [-Wlogical-...
Nicknapoli82's user avatar
2 votes
Accepted

cs50 make mario Hello I'm new to cs50 course when doing make mario i got this error

This is a very, very basic mistake, but something you'll instantly learn not to repeat. The C language is case sensitive. while is the keyword that should be used, but While is unacceptable. Note the ...
Cliff B's user avatar
  • 68.8k
1 vote

Why is this while loop generating errors

I'm not entirely sure about the logic of your conditions but putting the and (&&) conditions in brackets () should fix it. This is what you have: while(C< 0 && C < ...
donyd's user avatar
  • 90
1 vote

Pset1 Greedy; problem with do-while loop

Your while loop does not end up EDIT: (Thanks to SuperNovaCoder for your intervention) The problem is that equality must be achieved ie the conditions must be >= EDIT1: while(cent_amount>=0) ...
MARS's user avatar
  • 5,169
1 vote
Accepted

Do-while loop in pset1 returning negatives

Your code is actually doing what you told it to, but you told it to print out the number of bottles before it exited the for-loop. A simple fix is to put the printf outside the for-loop. If you still ...
SuperNovaCoder's user avatar
1 vote

Problem in the do..while loop in Mario.c

The declaration of your main function needs to be as so: int main(void) { ...code... } Notice the positions of curly braces relative to the declaration and the lack of semi-colons.
Steve Bunting's user avatar
1 vote
Accepted

pset1 mario.c this works, but can I better optimise?

My solution is very similar to yours. The printf("%s", " "); could be changed to printf(" ");. You could (not sure if you should) combine the two for-loops for(int j = 0; j < h-i-1; j++) //...
Blauelf's user avatar
  • 20.9k
1 vote
Accepted

Do While loop running even if not needed

Your analysis is correct. Perhaps you might want to review class materials on the difference between while loops and do/while loops? A do/while loop is guaranteed to run at lease once because the ...
Cliff B's user avatar
  • 68.8k

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