Questions tagged [dowhileloops]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
11 views

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

#include <cs50.h> #include <stdio.h> int main(void) { int n; do { n = get_int("Width: "); } While (n < 1); for (int i = 0; i < 4; i++) ...
0 votes
2 answers
80 views

Do - While loop

I am trying to do the Mario problem with C. The issue is that I want the user to select a number from 1 to 8. So my boolean expression is (n < 9 && n > 0). But I don't know why is not ...
1 vote
3 answers
140 views

Why is this while loop generating errors

I'm trying to get a 15 or 16 digits numbers (integers) from users and then using a do while loop to check if the user entered a valid number, otherwise, they will be re-ask to enter the number. THE ...
0 votes
1 answer
215 views

Pset1 Greedy; problem with do-while loop

When I try to run my code, I get prompted for the change amount, as desired, but when I enter an amount, nothing else appears in the terminal and the program does not calculate the minimum number of ...
  • 3
0 votes
2 answers
112 views

Greedy algorithm1

#include<cs50.h> #include<stdio.h> #include<math.h> int main() { float f=0; long int a=0,c=0; printf("Enter the float value:"); do { f = get_float(); }while(f <= 0); a = (...
0 votes
2 answers
381 views

Do-while loop in pset1 returning negatives

I can't get the do-while loop in water to work. It will take a positive number and then return the right thing and quit the program, but if given a negative number it spits out a negative water amount ...
  • 3
1 vote
1 answer
266 views

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

before you block my answer for duplicates, I've spent over a day on this small bug. I've searched reddit, youtube and the stack exchange forums and still can't get it to work. I'm hopeless at this ...
  • 11
0 votes
1 answer
88 views

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

Here is my code: include include int main(void) { int h; //gettin some input. do { h = get_int(); printf("height:\n"); //prompting for input. } while (h <= 0 || h > 23); //...
0 votes
1 answer
30 views

Do While loop running even if not needed

I think I am quite far with greedy, but I still have a big problem with my do/while loops. The problem I think is that when the code progresses, it automatically reads all the do/while loops and ...
0 votes
1 answer
472 views

Problem with the Do While loop for Mario

I am testing the first part of my code for Mario, pset1. I am using a do while loop because I thought the 'while' will return to the 'do' part if you put in a invalid number. But when I use the ...
  • 179
0 votes
1 answer
127 views

Pset 1 Bug with Do While Loop

My Do While Loop isn't working for some reason, the error is outlined below. Can anyone help me figure this out (I included the stdio and cs50 libraries)? int main(void); int n; { // error: expected ...
  • 19