A while loop is a control structure used in many languages to loop over a set of instructions as long as a particular condition is met.

learn more… | top users | synonyms (2)

1
vote
1answer
28 views

Loop to create random numbers, read from existing array, then create new array — Stuck in While-Loop

I have a doozy of a conundrum. Conceptually, I think I know what I need to do. Code-wise, I'm not so sure. I want to go through the AVAIL_NURSE_W1[] array (which holds the number that corresponds to ...
0
votes
2answers
71 views

String Loop Java

After giving the input to writtenBooks, it skips the option to enter input for authorDemographics and continues to the next prompt. At this point, regardless of the input i typed it continuously ...
0
votes
2answers
25 views

Java TreeNode while statement

I am working on code for a java TreeNode. I will like to do a while statement to loop through from the root of the tree to all subsequent nodes and update numbers. I can do this with an if statement ...
1
vote
0answers
64 views

Loop to create random numbers until condition is met, arrays involved [on hold]

I have a doozy of a conundrum. Conceptually, I think I know what I need to do. Code-wise, I'm not so sure. I want to go through the AVAIL_NURSE_W1[] array (which holds the number that corresponds to ...
1
vote
3answers
34 views

Comprehension difficulties regarding Boolean operators and whileloop

I am working on "Learn Python the hard way" and have a little understanding question regarding while loops and boolean operators. def bear_room(): print "There is a bear here." print "The ...
-7
votes
0answers
52 views

How do ifelse and while work in C? [on hold]

A bookstore has many customers and each one of them has an account with a credit limit which must not be exceeded. The bookstore owner requested you to develop a system by using C programming language ...
-1
votes
0answers
17 views

in my result array there is more than 1 data , then how i get last values from result array by using while loop [on hold]

This is my query select distinct date from table where 'some conditions' order by date descending limit 0,1; This will return 1 or 2 values to the result array , then how can i get last value ...
1
vote
4answers
41 views

CPU usage increases for Empty Infinite While loop

Can anyone explain me why the following Infinite loop takes a lot of CPU usage (CPU usage has increased upto 50% if total core is 2 and 100% if total CPU core is just 1) But if I un-comment the line ...
1
vote
3answers
35 views

basic while loop concept

Here is the correct code for evaluating if two strings are equal in length and character. function equal(x, y) { if(x.length != y.length) return false var i = 0; while(i < ...
0
votes
1answer
25 views

Testing with an infinite loop, is my application timing out? (C# using a PLC hardware input)

So I am testing this script here to determine which input is being read into my C# application. I am doing the following that is working at the moment 1: setting breakpoints at each if statement 2: ...
0
votes
1answer
21 views

Update table with While loop reading id first

I just wanted to ask something, I want to update a table, but this table 300k rows, it is taking about 1.8 - 2.3 seconds per row this is the table I need to update, if name match with a column i need ...
0
votes
3answers
60 views

My do-while statement doesn't seem to work

I'm completely new to coding and I was wondering if you guys can help me. This is part of a code in which you battle a vampire, RPG style. My program does not loop back to my characters turn after I ...
-4
votes
1answer
40 views

While loop not working when boolean changes? [on hold]

The while loop within my code at the bottom does not work, as when a character dies, and finished changes to True, it still keeps looping, does anyone have a fix for this? I have looked over this ...
-2
votes
2answers
26 views

undefined variable error in while loop PHP - ACCESS [on hold]

I am getting data from couple of queries in a php page. All the loops and queries are working perfectly but I am getting error in the following one. ERROR ONE: $sql_pso_sign="SELECT * FROM Table"; ...
0
votes
0answers
22 views

Get the next sunday after a date. Why is my loop and adding date components not working correctly?

I want to find the next sunday (or other weekday) after a given date I have this code snippet: NSDateComponents *dayComponent = [[NSDateComponents alloc] init]; ...
-1
votes
0answers
14 views

How to realign items inside a while loop

hey I am having trouble aligning this containers for my Hospital System. I need some code that can fix this ugly sight each container contains a patient, but when it stretches out to fit in the text ...
2
votes
1answer
41 views

Algo Issue - Find a group of item in a list

Here is what I'm trying to do : I have 2 lists. List 1 : 00F0001,00F0002,00F0003,00F0004,00F0005,00F0006,00F0007,00F0008,00F0009,00F0010 List 2 : 00F0006,00F0007,00F0008 (this list is generate by ...
20
votes
8answers
2k views

How does continue work?

I am trying to understand how "continue" works. I understood the concept of the keyword but when I run different programs, it works differently :-/ Let me show you few examples: If I run this program ...
-1
votes
4answers
65 views

Strange condition in a while loop

I was looking through some exam tasks to my informatics course and came across a confusing line of code in one of them: while(a % b) { //body of the loop } I was sure that the condition should be ...
0
votes
1answer
25 views

while read line strange output

I have a script which reads a file line by line. Each line has many columns separated by white spaces, like: 1a 1b 1c 1d 2a 2b 2c 2d 3a 3b 3c 3d I want to act on the first column of each ...
3
votes
2answers
54 views

Interrupt cin while loop without the user entering input

In main, I give the user the ability to enter a command to stop the application: while( run_processes && cin >> command_line_input ){ I'd also like to stop the application elsewhere ...
-4
votes
0answers
20 views

How do I Contact a DIV Class Using JavaScript , not jQuery? [closed]

I'm new to Javascript and studying loops. I want to try contact a div and just somehow loop it to go back and fourth across the screen without using jQuery because I've a Javascript exam coming up, ...
-1
votes
0answers
42 views

PERL Cisco Config Parser / Interface status [on hold]

I am trying to write a script that can read in a cisco router config, specifically the interface sections, in as an array. Once the interface section is read in, i would like to be able to search the ...
2
votes
2answers
45 views

Morse Code Translator - Can't seem to convert from morse-to-english accurately

So I have an assignment due and I have spent ages trying to figure out a specific part of the problem, but keep coming up with nothing. I finally 'gave up' and decided to come here for a little ...
0
votes
2answers
23 views

Populating Java ComboBox with Array data

on my personal quest to learn some Java I have come across another hurdle. So far I have 2 arrays, the first one is a 1D array with a list of photographic film manufacturers, the second is a 2d array ...
-2
votes
0answers
29 views

have easy method for two while loops in php

i use 2 statements from while loop... week by week normally add database some rows.. now page is very slow.. so how can i fix this.. have another easy method?.. plz help me for this one... thanks ...
-1
votes
0answers
30 views

match search using while in Perl

I want to get matches from my file. But I also want to change my matches after judging with frequency. I found that my script change my matches two times. Can you solve this problem and explain about ...
1
vote
4answers
79 views

What's wrong with my While loop?

I tried to make a little program with Scanner but it says that my While loop is incorrect. The error message is: 'line cannot be resolved to a variable' I tried to fix this problem, but when I do, ...
0
votes
2answers
47 views

Changing the opacity of a div with a php while loop

After a button is pressed in my PHP script, the header location is changed to another page. I was wanting to do something a bit more unique, and make the inputs fade out before the page changed, this ...
0
votes
0answers
30 views

Why would a for loop cause a hang when a while loop works fine?

After spending some time looking through my functions to figure out what the issue was, I realised that an instance of a for loop was causing a hang when I called the function containing it. The ...
0
votes
2answers
50 views

Is this not the same logic? Different Results

I don't understand how these two codes are giving me different results? 1 int main() { struct stat buf1; struct stat buf2; FILE *fp1, *fp2; int ch1, ch2; clock_t elapsed; ...
0
votes
3answers
41 views

nested if statement not working using while read variable

I have a csv file that i am reading with a "while read" statement and i want to run an if statement on one of the fields in the csv. ==================================== csv file ...
-3
votes
1answer
32 views

MIT opencourseware - stuck on a basic issue, credit card minimum payment over a year calculation

Basically I'm pretty stuck on this issue, I've linked the question below, it's part 'b' I'm stuck on, or the second question in the document: ...
1
vote
1answer
48 views

A recursive must resolve to type but I don't know how to structure it?

public static Directory makePath(Directory parent, String[] path) { // While path has more than one item in it, recurse if (path.length > 1) { System.out.println(parent + "1"); ...
0
votes
2answers
13 views

Thread, breakpoint

I've written this little program in objective c. int x; x=1; while (x<60) { self.jalo.text = [NSString stringWithFormat:@"%i", x]; x = x + 1; } jalo is the name of the label. it ...
0
votes
5answers
56 views

c# if statement inside while loop how to break out if user inputs valid data

I would like to know what to put in the if statement brackets to tell the program, if x or y equals a double, it can break out and continue carrying out the rest of my code. Any suggestions? while ...
0
votes
2answers
42 views

Android While-Loop using Thread

im trying to make a thread that will run a While-loop and inside the while-loop actions that will change the UI should take place : public void GameHandler() { layout = (RelativeLayout) ...
0
votes
1answer
33 views

Increment function argument variable [Python]

I am trying to write a script that reads from an Excel file as a template, and then insert new data based on what is read from a .txt file. I am using the xlrd module for reading. Currently, I am ...
-3
votes
1answer
33 views

Python program crashes upon subtracting from the control variable in a while statement

This program is designed to grab a bunch of data from a spreadsheet and print it all out line by line. Code: import xlrd from time import sleep password = 0 username = 0 book = ...
0
votes
6answers
38 views

can “or” be used in the logical test for a while loop?

Not sure why this only seems to work with the response "yes"(or "Yes"/"YES") - any help would be appreciated. Pretty new to this! var yesNo = window.prompt("Are you from Earth?"); var lowerYesNo = ...
0
votes
3answers
18 views

mysqli fetch assoc returns only half of results

I want to create a function that returns all results from a mysqli query in an array. function Get(){ // verification... verification... $res = $this -> link -> query("SELECT " . $select . ...
0
votes
2answers
36 views

While loop not working in Android

I'm trying to make a while loop that will make a number count up. However, when the app runs, it just crashes. Here's the code I used: Thread Timer = new Thread(){ public void run(){ try{ ...
0
votes
3answers
54 views

Break out of the middle of a while loop, without repeating code

I'm asking users a series of questions and recording their answers. My question-askers check the formatting of these answers and return a flag if a user inputs something strange (like my name is 102). ...
0
votes
1answer
25 views

On button press, break out of while loop? - MATLAB GUI

I am having trouble breaking out of a while loop from an animated plot. Essentially, I have a MATLAB GUI with two buttons. One button starts an animated plot. The other button stops the animated plot. ...
0
votes
3answers
41 views

BASH: IF statement doesn't work with empty string from WHILE loop

The first if statement doesn't work if there is no output from the command. I also tried to evaluate the exit status but this also doesn't work? unhide-tcp output: # unhide-tcp Unhide-tcp 20130526 ...
-1
votes
3answers
41 views

Break from outer loop, break from while loop while inside it Python

I am trying to break out of a while loop or stop it from running with a command that is inside of the loop, and not at the end. Code: operandList = [] programRunning, operationRunning, operandRunning ...
-3
votes
1answer
56 views

expected while before elseif [closed]

I don't know why it says it needs a while or where to put it, and it gives the wrong answer for the LOCS function also is there anything i can do about the default pointer warning. this is just a ...
-1
votes
0answers
68 views

Simple Parallel Processing: OpenMP?

Having trouble converting this into parallel processing; I made some simple changes, ran it on Xeon Phi and the code below actually runs faster than my proposed parallel structure Here is my current ...
0
votes
0answers
39 views

SQL While Loop to find end of chain replacements/supersessions

I have read a bunch of information that processing a table RBAR is terribly inefficient, and while I know that was not what SQL was optimized for, I'm interested to see if there is a way that I can ...
0
votes
2answers
23 views

Setting function with setInterval() to act at some value

I've created start() function which counts from 1 onwards. I want it to do something after some time pass, for example 5 seconds. How to achieve that? I've tried with if (timecounter == 5) but that ...