Questions tagged [dowhileloops]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
2answers
51 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
3answers
109 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
1answer
185 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 ...
0
votes
2answers
91 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
2answers
369 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 ...
0
votes
1answer
230 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 ...
0
votes
1answer
79 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
1answer
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
1answer
422 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 ...
0
votes
1answer
122 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 ...