Questions tagged [do-while]

A do while loop, sometimes just called a do loop, is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition.

The do-while loop can be found in most computer languages and can be thought of as a repeating if statement.

The syntax for the while loop for many computer languages is as follows:

do
{
    // loop body
} while (condition);

The do while construct consists of a block of code and a condition. First, the code within the block is executed, and then the condition is evaluated. If the condition is true the code within the block is executed again. This repeats until the condition becomes false.

Because do while loops check the condition after the block is executed, the control structure is often also known as a post-test loop. Contrast with the while loop, which tests the condition before the code within the block is executed.

(excerpted from http://en.wikipedia.org/wiki/Do_while_loop )

2862 questions
0
votes
0 answers

Select until in MySQL

I have this table the contains user_id and father_id. I want to select all the father_ids that are associated with the user_id until the value of the father_id = 0 and store them in a comma-separated format. Table: network select user_id, father_id…
Morgi
  • 1
  • 1
0
votes
0 answers

Using do-while loop in NodeJS to check existed in Firebase database

When a user registers a new account, I want to generate a reference code. I'm using the do-while loop for checking exists of the reference code in the database but the loop keeps running at least 2 times although the records in the database are…
HoangNA
  • 163
  • 1
  • 12
0
votes
3 answers

Bash - While read line from file print first and second column

I have a test file like below. (but the actual file has 1000+ lines and many columns) apple,2 mango,5 coconut,10 I want to print this file as below. I have apple and the count is 2 I have mango and the count is 5 I have coconut and the count is…
TheDataGuy
  • 2,712
  • 6
  • 37
  • 89
0
votes
1 answer

Using a closure in a do while loop for a get request

I have 5 endpoints I need to grab information from. I can only grab 500 objects at a time. My thought process is that I need to loop through each endpoint and push the returned result to my object. I then nest the request inside of a do while loop…
Jghorton14
  • 724
  • 1
  • 8
  • 25
0
votes
2 answers

Loop does not move to next file

I have an issue with the below code. It seems to work fine but apparently it is not able to move to the next file in the directory given; it gets in fact stuck to the first file, and it reopens it, without being able to move on to the next one. Any…
GCoxxx
  • 65
  • 7
0
votes
1 answer

Excel VBA Do While Loop on 50k+ rows of data, 30+ minutes To Process

I am running a Do While Loop on a large excel file w/ 50k+ rows of inventory data and for the macro to sort through the data it takes my computer (mobile i5 6300u, 8gb ram) over 40 minutes to process (this is the point where I gave up and closed the…
Cptacorn
  • 3
  • 4
0
votes
1 answer

Java do-while loop not working

I am writing a program in Java and I am having trouble with a do-while loop. I have posted the code below, but I have removed most of the code for the sake of readability. What is happening when I run the program is that the first 4 lines in the…
Katherine Reed
  • 301
  • 1
  • 7
  • 20
0
votes
3 answers

How to compare strings without case-sensitivity?

I'm writing a code where the user has to input if he wants a feature or not by pressing "y" or "n" or writting "yes" or "no", without checking for case-sensitivity (so it needs to work if the user writes yES or YeS). Also, if the user writes…
0
votes
2 answers

Excel Do while to obtain adjacent cells when cell equals value

I have two sheets. Sheet 1 (Customer tracker - OC) has a column which contains either yes or no for every row. If the value is yes , the two adjacent cells to the right have two values in them. I would like to create a do while / for each macro that…
0
votes
4 answers

ending a do-while loop

Ok I have a do-while loop that's supposed to end when the use hits 'q' but it is giving me the error message instead please help. package Assignments; import java.util.*; public class assignment3 { public static void main(String[] args) { …
Brad
  • 49
  • 2
  • 7
0
votes
1 answer

vb.net do while excel cell value is not "test value"

I'm a new VB.net user (and completely self taught). I'm trying to search down column A of an excel workbook (starting at "A1") to check the cell contents. On finding a specific value, I want to msgbox out which cell it is in. Can anybody help me in…
pbuffh
  • 9
  • 2
0
votes
3 answers

My do-while loop isn't looping

Hello everybody I'm really close to finishing this but I'm having problems with my for loop. I need my program to have a user enter either a 'w' or 'h' to have them enter a new weight or height. When they do my loop seems to stop for some reason. …
Brad
  • 49
  • 2
  • 7
0
votes
1 answer

How are the do-while loops compiled?

The questions is a lot more specific than the title actually. I'm just going through some C# and I come across an error that I managed to fix but I don't know why. Why does my do-while loop give me an error when the string power is defined in the…
ajdawg
  • 17
  • 1
0
votes
3 answers

syntax error , while/do expression,

package hw.loops.co.il; import java.util.Scanner; public class LoopsTargilMedium3 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int num; do { System.out.println("Please…
0
votes
1 answer

Why is this do while loop infinitely executing?

Why is this do while loop infinitely executing? #include "stdafx.h" #include using namespace std; int main() { unsigned int base; cout << "Base: "; cin >> base; for (int i = 1; i <= base; i++) { int j = 0; do { cout <<…