do-while Questions

3

Solved

The while loop Test the condition and if it is true, then execute the code The do..while loop Execute first time. Then test and execute. So the difference between while and do..while is , programma...
Ci asked 11/6, 2017 at 6:47

22

Solved

I need to emulate a do-while loop in a Python program. Unfortunately, the following straightforward code does not work: list_of_ints = [ 1, 2, 3 ] iterator = list_of_ints.__iter__() element = None...
Wellington asked 13/4, 2009 at 6:18

9

How do I write a Do .. While loop in C#? (Edit: I am a VB.NET programmer trying to make the move to C#, so I do have experience with .NET / VB syntax. Thanks!)
Letishaletitia asked 29/3, 2010 at 15:13

4

I'm planning to use a do-while loop in MATLAB. Is there a way to do that?
Paisano asked 17/2, 2013 at 10:38

5

Solved

What is the best way to emulate a do-while loop in Bash? I could check for the condition before entering the while loop, and then continue re-checking the condition in the loop, but that's duplica...
Berthold asked 10/5, 2013 at 19:49

9

Solved

Why am I not allowed to use a variable I declared inside do and use it inside the while part of a do/while loop? do { index += index; int composite = index + 1; // more code here } while (Unset...
Trichomonad asked 1/9, 2015 at 14:31

6

Solved

I want to have a while loop do something like the following, but is this possible in c++? If so, how does the syntax go? do { //some code while( expression to be evaluated ); // some more code...
Sweetmeat asked 27/11, 2009 at 6:33

31

Solved

Possible Duplicates: While vs. Do While When should I use do-while instead of while loops? I've been programming for a while now (2 years work + 4.5 years degree + 1 year pre-college), an...
Quinary asked 27/7, 2010 at 19:9

7

Solved

How to do code something like this in groovy? do { x.doIt() } while (!x.isFinished()) Because there is no do ... while syntax in groovy. No 'do ... while()' syntax as yet. Due to ambiguity, we...
Cupo asked 4/1, 2014 at 13:20

2

Solved

More often than not we need loops like this do { Type value(GetCurrentValue()); Process(value); }while(condition(value)); Unfortunately this will not compile, because value's scope ends at }. ...
Depravity asked 8/11, 2012 at 20:27

2

Solved

This is quite a beginner question but I'm wondering why my do...while loop is not closing. The program is supposed to loop while the user input is not 'C', 'c', 'F', or 'f'. It seems to close when ...
Ancillary asked 25/8, 2021 at 4:24

2

Solved

Why doesn't Python have a 'do while' loop like many other programming language, such as C? Example : In the C we have do while loop as below : do { statement(s); } while( condition );
Pintail asked 17/5, 2016 at 16:18

2

Solved

StudentAnwser=() inputScriptFile=001.sh while IFS= read -r line; do StudentAnwser+=( "$line" ) done < <( sh $inputScriptFile test.txt ) it returns a error foo.sh: line 22: syntax error n...
Bergren asked 22/3, 2016 at 1:19

7

Solved

MDN states: When you use continue without a label, it terminates the current iteration of the innermost enclosing while, do-while or for statement and continues execution of the loop with the ne...
Pop asked 30/6, 2012 at 13:20

4

I have a loop inside a C# method that has the following structure. do { getUserInput(); if (inputIsBad) { doSomethingElse(); } } while (inputIsBad); alternately, with a while loop: getUse...
Caseinogen asked 26/1, 2020 at 0:46

1

Testing cin for non numeric, non zero,and non negative values and entering loop. Cannot see why the test for values <=0 portion is not working. it should output: cout << "Invalid value in...
Swinge asked 20/10, 2019 at 19:56

3

Solved

What's the difference between Do While where the statement is the first line in the loop block and just the single While in VB.NET? They don't seem to offer any difference in behavior.
Milklivered asked 17/4, 2013 at 10:55

4

Solved

I am trying to get make a random number generator that generates a string of numbers between 1 and 9, and if it generates an 8, it should display the 8 last and then stop generating. So far it pr...
Prieto asked 17/8, 2017 at 13:15

8

Solved

I am a beginner java and trying to solve tricky problem input=777 output should be 3 7+7+7=21 , 2+1=3; From the above code if my input is 333 I am getting 9 as answer but when the sum is two digit...
Dahle asked 23/8, 2015 at 8:43

3

Solved

I am working on Do While loop in my project its working fine first time. Before while statement, I assigned a value to an array I could able to print the array successfully at bottom of the code,...
Mathias asked 18/11, 2018 at 20:18

12

Solved

This is a highly subjective question, so I'll be more specific. Is there any time that a do-while loop would be a better style of coding than a normal while-loop? e.g. int count = 0; do { Syste...
Tropology asked 9/12, 2013 at 13:45

6

Solved

When it comes to counting, should a do-while loop be used, or a for loop? Because this: class Main { public static void main(String[] args) { int times = 1; do { System.out.println("I have pri...
Dolichocephalic asked 9/10, 2018 at 20:36

4

I am new to coding and I'm trying to do a long do while loop with nested if statements but I'm having issues with getting my loop to actually loop. Instead of getting help directly on my pr...
Monticule asked 9/10, 2018 at 8:58

2

So I have some code centered around a do while loop. string token; var count = 0; var checkDataLength= data.Length == 16; do { count = 0; token = GenerateToken(data, start, end); if (check...
Comeon asked 18/7, 2018 at 20:22

5

Solved

In Why can't you declare a variable inside a do while loop? the OP asks why a declaration in the while-condition of a do-while loop isn't in scope in the do-statement. That would be very unnatural ...
Hieronymus asked 13/12, 2014 at 15:35

© 2022 - 2025 — McMap. All rights reserved.