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

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 ...
  • 66.7k
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 < ...
  • 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) ...
  • 5,201
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 ...
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.
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++) //...
  • 20.8k
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 ...
  • 66.7k
1 vote
Accepted

Problem with the Do While loop for Mario

Look at the test in the while loop: while (hight < 0 && hight > 23); The while loop will repeat when the test condition is true. So with that in mind, can you tell me any number that ...
  • 66.7k
1 vote
Accepted

Pset 1 Bug with Do While Loop

Simple problem. You put a semicolon in int main(void); The correct structure is: int main(void) { // code goes between curly braces } You also have a declaration statement, int n; before the ...
  • 66.7k

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