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
1 answer

printf executes multiple times only on certain inputs

Program executes the printf command multiple times when the input is "08" or "09" and not in some other similar number, say "03" or "07". do { printf("Enter date:"); scanf("%i/%i/%i", &d, &m, &y); } while (d !=0 || m != 0 || y != 0); This is the…
callmeanythingyouwant
  • 1,789
  • 4
  • 15
  • 40
0
votes
0 answers

Create Dynamic do-while statement in Java?

I've been wondering for a moment, is it possible to create a dynamic do-while statement in Java (with function/method)? I've been working around, and have this 'semi-automatic' function work: import java.util.*; public class Test{ Scanner inp =…
Gregory
  • 1
  • 3
0
votes
2 answers

scanning an integer ONLY into an array

As a part of an assignment I've got, I need to get from a user a digit only using the library. do { scanf("%d",&num); } while (num>9 || num<0); But the program will get from the user also chars and other things. Any advice?
Tal Alfi
  • 35
  • 6
0
votes
2 answers

double loop Quit first or repeat

I would like to be able to exit the script after using option 1 and Q. R for repeat works and any other key would bring me back to the Menu before. Can i just use another while ($response -eq "Q") ? or is the do while loop just wrong for that? i…
batchn00b
  • 29
  • 7
0
votes
1 answer

Program for calculating sine and cosine of angles inputted by user

I have been trying to code a program whereby the user inputs an angle, assuming it is degrees, it gets converted from degrees to radians and then calculates its sine or cosine. I tried to do this in a way which is convenient for the user but it…
Redent
  • 33
  • 7
0
votes
2 answers

Scan two variables in a do-while loop in c

I am trying to create a do-while loop that scans two variables but when I type "exit", I want the function to go out the loop. This is my code: char var1; char var2; do { scanf("%s %s", &var1, &var2); } while ("Some argument that I don't…
786534854
  • 3
  • 1
0
votes
1 answer

mySQL while exists with select data not recognozed in loop

I have a stored procedure where I call a different stored procedure that creates a temp table and then use that temp table in a while exists loop. When I go to use the field names in the while loop, I am getting an error that one of the fields from…
EddiRae
  • 47
  • 8
0
votes
1 answer

Looping AndroidNetworking.post passing all data don't update on SQLite after Response Success

I'm having a problem updating data from SQLite when API response are success, for example, I have 5 pending data, My codes are getting and sending data from database. but only the last data had update in SQLite. I have logged…
user9064724
0
votes
4 answers

Try-Catch with Do-While loop

I'm studying a C # course and doing my second task. I've been able to get the code done. The only thing I can´t code is how to use and where to use Try & Catch. Since I'm new to C #, I don´t know how to code it. I've searched for solution but most…
S. Gunel
  • 13
  • 1
  • 6
0
votes
0 answers

Execute and Stop Many Loops Shell

I currently have a loop this way (working perfectly): while true; do /usr/bin/R_START; sleep 0.1; done The script "R_START" uses the lines of a text file named "FILE.TXT", they are deleted as soon as the script executes its instructions. I wonder…
logvca
  • 57
  • 7
0
votes
3 answers

Longest sequence of the same number&how many longest seqeuences exist (without array)

In C, I'm only allowed to use stdio.h and I'm not allowed to use arrays. The question is: I need to write the function "void MaxLegnth()" that inputs integers as long as they're positive, if it inputs a negative number, the inputting part will stop.…
0
votes
1 answer

How to keep a program checking to see if the while loop becomes true Java

My Code: import java.time.*; import java.time.temporal.*; class { public static void main(String[] arguments) { LocalDateTime now = LocalDateTime.now(); int Seconds = now.get(ChronoField.SECOND_OF_MINUTE); do{ \\ My Code is…
Jacob Kiss
  • 1
  • 1
  • 2
0
votes
2 answers

PHP list while loop

how do i put list in while loop? PHP: > $q = $db->query("SELECT * FROM > bs_events LEFT JOIN bs_reservations ON > bs_reservations.id_event = bs_events.id > GROUP BY bs_reservations.id_event > ORDER BY bs_events.eventDate ASC LIMIT 20"); HTML…
tonoslfx
  • 3,422
  • 15
  • 65
  • 107
0
votes
0 answers

Undesired behavior while making loop menu

as the title suggests, I've tried making a sort-of interactive menu in two ways: one with a loop and the other by making a recursive function. Either way yields the same behaviour, that is, it "takes" my first input as the one for when it should be…
0
votes
1 answer

Nested Do While

I am trying to run code that does the following: 1) Find record with matching index number 2) In row that match was found, check conditions 3) If conditions are satisfied, then record an index number stored in a column within the same row as a new…
1 2 3
99
100