Questions tagged [while]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
5 views

Looking for a way to make a loop that rejects an input with any other hour format other than the one specified

Im having trouble creating a code on C that after letting the user input a date it determines if the date is in a valid 24 hour format, any help would be greatly appreciated. Here's my code. #include &...
Jorhan López's user avatar
0 votes
1 answer
66 views

credit pset1 cs50 sum while loop

I was doing the credit problem with the visa test card in the page: 4003600000000014 It passed that test, however in other tests it doesn't pass. I think it's a matter of the sum that it can't compute ...
Thom OM's user avatar
0 votes
2 answers
64 views

Why does this become an infinite loop?

I am trying to make a pyramid of hashtags somehow which I haven´t figured out yet, and trying my way step by step. (I´m doing the Cs50 course) When I came this far the program is working wohoo so far ...
l_b's user avatar
  • 7
-1 votes
2 answers
181 views

while (n<1) ----- Why?

Week 1 - mario exercice. Into the program below , I do not understand why while (n<1) As width is a positive value, n shouldn't be >1 ? -----------------------------------------------------------...
Freko's user avatar
  • 1
0 votes
1 answer
29 views

CS50 Recover - Cannot figure out why my While loop is not being invoked

When I run the following code, it doesn't appear as if my while loop is being invoked because it never prints the print statement, but I cannot find a reason why it is not running the while loop. #...
M2718's user avatar
  • 5
0 votes
2 answers
857 views

While Loop in C only executing once and then stopping

I have created a function in C that tests if an integer in between a range of 100 (min) and 500 (max) - The function calls on another function called "getInt()" which tests whether the integer is ...
bbNicky's user avatar
  • 11
0 votes
1 answer
580 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 (" "...
user avatar
0 votes
2 answers
344 views

clang doesn't like while loop

int main (void); int x = 0; while (x < 100) x = x++; { printf ("here we go, %i /n", x); } The errors I get are: loopwhile.c:8:1: error: expected identifier or '(' while (x < 100) //if ...
Rick's user avatar
  • 21
0 votes
1 answer
42 views

Second condition doesn't seems to work properly

I've just solved my mario.c pset1, everything seems to work, but when I enter a value over 23 like 50 or so, the code is still running and drawing the pyramid then re-prompt the height. I've tried to ...
Amine Marzouki's user avatar
0 votes
1 answer
151 views

while loop not working

I got my greedy program to work and I mainly used for loops. I tried to recreate it with while loops, but I'm doing something wrong. Whenever the GetFloat() line is executed and the user gave a number,...
Bram  Vanbilsen's user avatar
1 vote
1 answer
108 views

pset3 - Breakout - Can't start again after loosing my first live

All my program work well till I lost my first ball. After that, I'm not able to start with an other one. I thought I've controlled that with my second while loop. There the first part of my code in ...
CharlesD89's user avatar
0 votes
3 answers
411 views

Pset 4 recover same thing, again

/** * recover.c * * Computer Science 50 * Problem Set 4 * * Recovers JPEGs from a forensic image. */ #include <stdlib.h> #include <stdio.h> #include <stdint.h> typedef ...
Jedi18's user avatar
  • 17
0 votes
1 answer
128 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 ...
K. Roe's user avatar
  • 19
0 votes
1 answer
509 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
1 answer
301 views

my while loop is not working

i wrote the following code in orde to get familiar with the while loop However , instead of executing the loop when i give a number lower than 1 it does the exact opposite !it executes the loops ...
VAPORAS's user avatar
0 votes
3 answers
551 views

Do While Loop Bug in CS50.H with getInt()

I have two sets of similar Do While codes files, one with stdin scanf function and the other getInt() from cs50 lib. Both files compile in CS50 appliance. I expect the do while works the same but ...
Lim Shan Kuo's user avatar
-2 votes
1 answer
102 views

if else in a for loop [closed]

this code Works #include <cs50.h> #include <stdio.h> #include <string.h> int main(void) { int k; printf("write as trin\n"); string s= GetString(); for (int i=0; i<strlen(s);+...
pavlos romios's user avatar