Questions tagged [while-loop]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer

Recover PSET 4 Week 4 - skipping while loop

This is a follow up to my previous question. After I went through my code on debug50 it shows that my while on line 35 is not going through. I checked my code with other others on this site and they ...
Raheel A's user avatar
0 votes
1 answer

What is the problem with my get_int for the lab 1 question population in C?

when i make the code and i type ./population, the question asked is start size:, and when i type in an x value that is 9 or more, the question keeps reprompting and I keep looking through and I don't ...
Damien Lim's user avatar
0 votes
1 answer

lab 4: volume question

I was wondering if someone could help explain why an while loop cannot be used for the copying of the header for the .wav file. I originally used a while loop like the one from the cp.c in the ...
Tressa Sharma's user avatar
-1 votes
2 answers

While loop for recover pset4

I need a plain English explanation of how the while loop operates for the fread statement. After reading in the first 512 bytes, how does it loop to the next 512 bytes till it gets to the last block?
Olhuwhorlhey's user avatar
0 votes
1 answer

What is probably wrong in this while loop?

I'm getting positive integers from users. I used a do-while loop to check and validate that the user input is: 1. A positive integer. 2. The length (I.e size) is between 13 and 16 digits BUT NOT ...
KeleosWilliam's user avatar
0 votes
1 answer

Pset1 Cash Understanding modulo operator and while loops

I'm trying to set up my solution to the Cash problem using modulo. The input seems to be working correctly so far. It only accepts positive numbers through the do..while loop. The problem I think I ...
SarahToenin's user avatar
0 votes
1 answer

Stumped on pset1 cash.c, please help me learn

I'm trying to create a solution for pset1 cash.c, the code below is not meant to be the final implantation, just a cursor to figure out the problem. When I run this code it works for values .01 to .05 ...
user avatar
3 votes
1 answer

pset2 Crack - Looping through fgets

I'm trying to loop through a text file (seven lines in the file, with aaaa, aaab, aaac, etc listed) with password guesses for pset2 Crack. I am able to open the file, and iterate through the lines. ...
Phil Brandvold's user avatar
0 votes
1 answer

while loop executes randomly

I am testing my implementation of the sort algorithm in pset3, so I added the code to generate pseudo random numbers so I could test. I found that the while loop only gets executed randomly. For ...
Dami's user avatar
  • 103
1 vote
1 answer

PSet1 While Loop to Print Spaces for Mario Not Working

I have approached this problem by using a forloop with two nested loops. The second nested loop works and prints the correct number of hashes. The first nested loops does not appear to working at all, ...
Alex Durante's user avatar
0 votes
1 answer

Can't break out of while loop in python

def main(): x = 0 while x not in range (1,23): getheight() if x in range (1,23): break for i in range (x): for j in range (x - j): print (" "...
user avatar
0 votes
1 answer

PSET6 Load - How To Approach? Also, Is It Better To Use While() Loop or For() Loop?

I watched the walkthrough for load, but I am struggling to understand what the problem set is asking for. What is load's objective, and what is the best way to approach load? I also don't know ...
SuperNovaCoder's user avatar
0 votes
1 answer

How to fix the "expression result unused" compilation error?

When I try to run this code through the compiler, I get the error: expression result unused referring to the line cents - 25; How do I fix this error? How exactly do I "use" the expression ...
user7489's user avatar
0 votes
1 answer

Pset3 breakout issue with the while live > 0 && bricks > 0

I am trying to create the while lives > 0 && bricks > 0 loop but either the ball doesn't bounce off the right wall or the paddle doesn't follow the mouse. My code is below. Please help been ...
JV305's user avatar
  • 29
0 votes
2 answers

pset1 Mario. Spaces work, hashes don't and i can't see why

So I have been working on CS50's pset 1, making marios half pyramid. I have been looking over other problems on this site and I've gotten this far. But I can't seem to see what the problem is with my ...
Ella Donaldson's user avatar
0 votes
1 answer

Do/while loop gives error of unused variable, pset1

I'm working on Pset1 and I keep getting an 'unused variable' error in my do/while loop. This is my code- int main(void) { printf("How much change is owed?\n"); float fcents = GetFloat()*...
Faith's user avatar
  • 22
0 votes
1 answer

Why does this program output 0?

This is a simple program, running in a loop, it prints out x + 1 forever #include <stdio.h> int main (void) { x = 2; while(true) { x += 1; printf("%d\n", x); } }...
chaneque's user avatar