Skip to main content

Questions tagged [do-while]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
24 views

do a+b while its not divisible by c

I am completely new to C and also programming, and I have to make algorithm for: a=2 , b=3 and add "b" to "a" and display results of it until its divisible by 7 I tried something like this but I cant ...
Jaroslav Dvorský's user avatar
0 votes
2 answers
109 views

Problems on mario (pset1)

I want to test how the do-while loop works. But I encounter a problem, which I've spent an hour working on but couldn't figure out a solution. Here's my code. int main(void) { int n; do { ...
bobby1208's user avatar
0 votes
1 answer
206 views

Why is it that the OR (||) doesn't work while the AND (&&) works in my program?

When I typed while (c != 'Y' || c != 'n' || c !='y' || c != 'N'); , my program just loops over, and over, and over again, even if I don't fulfil the condition, AKA, if I enter values Y, y, N or n. ...
Jon's user avatar
  • 3
0 votes
1 answer
156 views

Pset1 Water Issue, reprompting with "Retry: " for Non-integers, and "Minutes: " for negative integers

My water program seems to work decently, it passes all of the check50 tests just fine. My issue is that when the user enters a negative integer, the program re-prompts with "Minutes; ", but when the ...
Matthew G Robbins's user avatar
0 votes
1 answer
2k views

Mario Less Comfortable, do-while loop problem

Hi everyone I made sure to do my research and go through the already posted questions. I am certain my while condition is wrong after research but don't understand the correction. my program runs but ...
TheWardedCoder's user avatar
0 votes
1 answer
102 views

Greedy - Do While Negative Float

I'm testing the very first requirement of the Greedy assignment (ensure the input is not negative). I'm running into an issue where if I use < 0 in the while statement, -0.1, -0.2, -0.3 etc. is ...
soziblewuup's user avatar
0 votes
1 answer
87 views

pset1 water how to ignore negative number

On the screenshot is the result after I typed a negative integer. How do I ignore the negative integers on bottles' result? Help pls. The positive & zero results are just fine, but the negatives ...
Anku1's user avatar
  • 3
0 votes
1 answer
218 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 ...
ahl89's user avatar
  • 3
0 votes
1 answer
56 views

PSET1 mario.c why if and return

I was banging my head with this. I had to look at others solutions to get my code to work. Here is the code I have, it works now but only because I looked at solution. I had this code written minus ...
Patrick Fisher's user avatar
0 votes
2 answers
383 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 ...
Jolie's user avatar
  • 3
0 votes
1 answer
147 views

Codestyling and whitespaces are important in Python? PSET6 [duplicate]

codestyling and whitespaces are important in Python? I have this simple code and works... import cs50 while True: print ("Type a number between 0 and 23: ", end="") n = cs50.get_int() ...
user avatar
0 votes
1 answer
621 views

Can't get the do-while loop to work in pset1

I have been trying to follow the walk through for pset1 and I cannot get my code to work for the first part of water. It will not let me execute the do-while loop. I have written the code just like ...
Josh Zinger's user avatar
0 votes
1 answer
138 views

PSET 4 recover.c - segmentation fault, do while loop

I have almost written working a recover.c. But when I want to use do while loop, memory segmentation fault appears. Of course I can write a code in a different way avoiding do while loop, but I want ...
Daniel's user avatar
  • 5
0 votes
1 answer
33 views

Do While loop not executing for pset3

I am working on Pset3 for a binary search algorithm. Below is my code (NOTE: the logic is not finished): bool search(int value, int values[], int n) { //binary search algorithm int min = 0; int max = ...
jaguar's user avatar
  • 70
0 votes
1 answer
538 views

do while loop not looping

I am having a problem with my do while loop. do { //this thing } while (n < 0 && n > 23); when I run it every time I enter a number ether valid or invalid it ends my program.
RicochetRiot's user avatar
0 votes
3 answers
194 views

PSET 1 Mario Code Problem

Would someone be as kind as to tell me what I got wrong for this section of my code? Thanks so much in advance!
SL824's user avatar
  • 17
0 votes
2 answers
940 views

pset1 "expected identifier error in do-while loop

I have been struggling with this for weeks now, have done several searches and posts and can not seem to get around this. I have tried everything and it just makes it worse. I wish there was a video ...
Richard 's user avatar