473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

while-loops enter the last time after condition is filled?

it seems to me from my results that when i use a while-loop it will
execute once after the condition is met.

ie the conditions is met the code executes one time more and then
quits.
Apr 5 '08 #1
4 1438
it seems to me from my results that when i use a while-loop it
will execute once after the condition is met.
Nope.
ie the conditions is met the code executes one time more and
then quits.
Must be that your conditional is wrong, or your conditions are
not updated the way you think they are.

-tkc
Apr 6 '08 #2
On Apr 6, 9:53 am, skanem...@yahoo.se wrote:
it seems to me from my results that when i use a while-loop it will
execute once after the condition is met.

ie the conditions is met the code executes one time more and then
quits.
The syntax is this:

while condition:
do_something()

Do you mean that it executes do_something() only once, but you expect
it to execute more that once?

Or should we interpret your seemingly inconsistent statement by
changing "condition(s) is met" to "condition(s) is NOT met" -- in
other words, it is executing one EXTRA time after you expect it to
have stopped?

Perhaps you should supply a short example of runnable code (including
print statements to show what is happening), the actual output that
you got when you ran that code, and what was the output that you
expected.
Apr 6 '08 #3
On Apr 6, 4:53*am, skanem...@yahoo.se wrote:
it seems to me from my results that when i use a while-loop it will
execute once after the condition is met.
Perhaps your condition is wrong. Please provide the code where this
occured.
Apr 7 '08 #4
On 6 avr, 01:53, skanem...@yahoo.se wrote:
it seems to me from my results that when i use a while-loop it will
execute once after the condition is met.

ie the conditions is met the code executes one time more and then
quits.
The problem is obviously in your code, but since you failed to post
the minimal code exhibiting the problem, we can't help.
Apr 7 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Brittany | last post by:
can someone explain to me what if else staments do and what while statements do.
33
by: Diez B. Roggisch | last post by:
Hi, today I rummaged through the language spec to see whats in the for ... else: for me. I was sort of disappointed to learn that the else clauses simply gets executed after the loop-body -...
4
by: James E Koehler | last post by:
I can't get the WHILE statement to work in MySQL. The version of MySQL that I am using is: Ver 12.16 Distrib 4.0.6-gamma, for Win95/Win98 (i32) running on Windows MX. Here is the relevant...
9
by: JS | last post by:
#include <stdio.h> main(){ int c, i, nwhite, nother; int ndigit; nwhite = nother = 0; for (i = 0; i < 10; ++i)
36
by: invni | last post by:
I have a nested while. How do I go from the inner while to the beginning of the outer while? Can this be done without using goto? while_1() { some codes here while_2() { if true go to the...
147
by: Michael B Allen | last post by:
Should there be any preference between the following logically equivalent statements? while (1) { vs. for ( ;; ) { I suspect the answer is "no" but I'd like to know what the consensus is
6
by: John Pass | last post by:
What is the difference between a While and Do While/Loop repetition structure. If they is no difference (as it seems) why do both exist?
8
by: yuyang08 | last post by:
As we all known, each for-loop can be expressed in while statement. Can we also say that each while statement can be expressed in for-statment? Thanks! -Andy
2
by: kya2 | last post by:
I am not able to create following store procedure. CREATE PROCEDURE DBSAMBA.InsertDeleteBatch(OUT norows INT ) RESULT SETS 1 LANGUAGE SQL BEGIN part1 DECLARE TOTAL_LEFT INT DEFAULT 0; ...
5
by: maestro | last post by:
why does this work? "while p" = "while p != 0" ? 1 is True and 0 is false in python but other numbers have no boolean value so why doesnt it abort. 16 print p p -= 1
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.