Questions tagged [while-loop]
The while-loop tag has no usage guidance.
16
questions
0
votes
1
answer
16
views
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 ...
0
votes
1
answer
65
views
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 ...
-1
votes
2
answers
87
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
1
answer
67
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
1
answer
249
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
1
answer
665
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
1
answer
360
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
1
answer
46
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
1
answer
106
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
1
answer
576
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
1
answer
69
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
1
answer
3k
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
1
answer
144
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
2
answers
475
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
1
answer
512
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
1
answer
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);
}
}...