Questions tagged [while-loop]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
-2
votes
1answer
46 views

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?
0
votes
1answer
52 views

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 ...
0
votes
1answer
203 views

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 ...
0
votes
1answer
601 views

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 ...
3
votes
1answer
337 views

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. ...
0
votes
1answer
41 views

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 ...
1
vote
1answer
105 views

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, ...
0
votes
1answer
507 views

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 (" "...
0
votes
1answer
66 views

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 ...
0
votes
1answer
2k views

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 ...
0
votes
1answer
139 views

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 ...
0
votes
2answers
457 views

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 ...
0
votes
1answer
358 views

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()*...
0
votes
1answer
23 views

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); } }...