Loop Definition and 1000 Threads

In computer science, a for-loop (or simply for loop) is a control flow statement for specifying iteration, which allows code to be executed repeatedly. Various keywords are used to specify this statement: descendants of ALGOL use "for", while descendants of Fortran use "do". There are other possibilities, for example COBOL which uses "PERFORM VARYING".
A for-loop has two parts: a header specifying the iteration, and a body which is executed once per iteration. The header often declares an explicit loop counter or loop variable, which allows the body to know which iteration is being executed. For-loops are typically used when the number of iterations is known before entering the loop. For-loops can be thought of as shorthands for while-loops which increment and test a loop variable.
The name for-loop comes from the word for, which is used as the keyword in many programming languages to introduce a for-loop. The term in English dates to ALGOL 58 and was popularized in the influential later ALGOL 60; it is the direct translation of the earlier German für, used in Superplan (1949–1951) by Heinz Rutishauser, who also was involved in defining ALGOL 58 and ALGOL 60. The loop body is executed "for" the given values of the loop variable, though this is more explicit in the ALGOL version of the statement, in which a list of possible values and/or increments can be specified.
In FORTRAN and PL/I, the keyword DO is used for the same thing and it is called a do-loop; this is different from a do-while loop.

View More On Wikipedia.org
  1. A

    Kleppner & Kolenkow find the tension of a rotating loop of string

    Hello, I am a high school student trying to learn physics out of Kleppner and Kolenkow. Unfortunately, the solutions to some of the problems are not available online, nor is a solutions manual available, so I am unable to find out where I am wrong in some cases, such as this one. I would...
  2. F

    Wire loop area induction sensor

    Hi, I'm working on an idea and i need some guidance say i have a wire loop of a single wire (not solenoid) the area of the loop is about 1-2 cm^2 now say i change the area of the loop slightly by about 0.1%-0.01% could i measure with today's electronics this slight change of L thanks in...
  3. K

    Based loop groups as homogeneous spaces

    Homework Statement Let G be a compact connected Lie group define the loop group and the based loop group as LG = \{ \gamma \in C^\infty(S^1,G) \}, \Omega G = \{ \gamma \in LG : \gamma(e_{S^1}) = e_G \} (choose whatever identification of the circle S^1 you like ). Show that \Omega G is a...
  4. S

    Loop Invariant in Analysis of Algorithm

    I can't generally map Loop Invariant method for proving the correctness of an Algorithm. Take the case of an Insertion Sort http://csnx.groups.allonline.in/pool/Introduction%20to%20Algorithms-Cormen%20Solution.pdf in the above link, at the page 2-3, they have proved the correctness of...
  5. U

    Java [JAVA] please tell me this for loop

    Hey guys, I have an ArrayList<String> al = ArrayList<String>(); and I have a textbox, the textbox allows a user to enter a word and that word will be added into the ArrayList. When I print the list out it looks like this [Cat, Dog, Mouse] can you please write out the for loop that I need...
  6. S

    Finding the minimum speed of a loop the loop and finding the height of the hill

    Homework Statement I have a hill with a roller coaster cart on it and it goes down and around a loop-the-loop the radius of the loop is 10m Diameter=20m What is the minimum speed the cart needs to go to keep it on the track? There is no friction, what is the height of the hill...
  7. S

    What Determines the Rider's Fate in Different Speed Domains of a Vertical Loop?

    3. Consider the motorcyclist riding on the inside of a vertical circle of radius b. His initial speed at the bottom of the circle is u. a) Explain why the three domains (i) u^2 < 2gb, (ii) 5gb > u^2 > 2gb and (iii) u^2 > 5gb are qualitatively different. b) Describe what happens in domain...
  8. D

    Fortran Creating a Loop for Sum of Digit Squares to Equal 1

    Hi, I'm writing a program in fortran that basically creates a loop from 1 until a certain number x (input by the user), and goes through each value between 1 and the certain number x in order to determine if each value meets certain criteria. The criteria is that the sum of the square of the...
  9. M

    Using the Loop rule to find potential Difference

    Homework Statement Find the potential difference between points a and b. Picture of Circuit involved. Homework Equations V=IR ΔV=Vb-Va The Attempt at a Solution Pretty much completely lost, due to the only one current shown I'm not sure which way the current flows through...
  10. D

    Is a vertical loop possible with a modern large airliner?

    I have asked many times this question to many people and have many different answers: Let X be a widebody jet airliner like an Airbus or Boeing, larger than a typical business jet. Can X do a vertical loop manoeuvre? If X cannot, what is it that stops X?
  11. L

    Changing part of a name of a variable in a for loop

    changing part of a name of a variable in a "for" loop hello everyone! let's say i have the equation between two variables: DT10sec= A*T10sec, working in matlab. How can i use a "for" loop to calculate the equation DT20sec= A*T20sec DT30sec= A*T30sec, DT40sec= A*T40sec,... etc How can i...
  12. M

    Misunderstanding something: circular time dilation loop

    Hi.. Speedo, flying in space, is at large speed compared to c relative to his brother on earth. Therefore, after a long time meeting at rest relative to each other, Speedo aged less than did his brother from his brother perspective. But from Speedo's point of view, his brother was also moving...
  13. P

    Mathematica Using an If loop in Mathematica

    Dear all, I have a list of pairs say Li={{a,x},{b,y},{c,z}...}. I want to eliminate from this list all pairs that have their second part i.e the x, y, z...>1 and I was thing of using an If loop. Can anyone tell me how please... Thanks...
  14. Ranger Mike

    How Can Closed Loop Drive Systems Achieve Precise 1000 mm Movements?

    Hello, I have a few questions regarding machine tool drive and feed back system. Say I have a 1 meter long guide way and a carriage that is driven by DC motor. This carriage glides on air bearings. The drive mechanism has pinch rollers that pinch a drive rod and these rollers are driven by...
  15. I

    Countercurrent condensation loop

    I will be attempting to make liquid nitrogen from air. Part of the process involves passing air compressed to 200 atm through a coil and rapidly expanding it. The expanded air that does not form liquid from the rapid cooling will pass back over the condensor coils in a counter-current fashion to...
  16. I

    Please help my for loop goes on forever (Matlab) :/

    Homework Statement Question: A ball is launched from a height of 12m. It should land in a pool that has a length of 22m and is 9m away from the wall. Find the minimum and maximum initial velocities for the ball to land in the pool. The ramp is angled at 1 radian such that vy = 0.54v and vx =...
  17. D

    MATLAB Matlab Difference Equation Loop?

    Trying to make a three line loop that would differentiate x2√4x+1 to the nth term starting from the original function (n=0) to the 5th derivative (n=5) and then substitute 2 into the derivatives. Here's what I got f = @(x) x2√4x+1 For n=[0:5] - As the nth term goes from 0 to 5...
  18. S

    How Does Amperian Loop Technique Determine Magnetic Fields in a Coaxial Cable?

    4. Consider a coaxial cable consisting of two infinitely thin conducting cylindrical surfaces with radii R1 < R2. A current I flows in one direction in the inner cable and in the opposite direction in the outer cable. Using the Amperian loop technique, determine the magnetic field a)inside...
  19. Roodles01

    Signal from dipole detcted at loop in free space

    Homework Statement A Hertzian dipole at origin generates a signal in empty space which is detected at a wire loop with position vector; r=(50m)ez Homework Equations Signal is detected by changing magnetic field; B(t)=B0 sin(2∏ft)ex Show it is consistent with the Maxwell's solution to a plane...
  20. haushofer

    Loop Quantum Gravity and Correspondence Principle

    Hi, I'm a non-expert on LQG, and have a question about it: What is the status of the correspondence principle applied to LQG? I.e., in which sense can we take the classical (h --> 0) or non-relativistic (c --> oo) limit in order to obtain classical GR or Newtonian gravity out of LQG...
  21. D

    For Loop Circuit - calculate the nth derivative of the signal

    For Loop Circuit -- calculate the nth derivative of the signal I'm trying to design a circuit that differentiate a signal using a differentiating amplifier. What I want to do is to calculate the nth derivative of the signal based on a count I specify. How can I apply the same amplifier to the...
  22. P

    Boosting a Current Loop: Effects on Current Density and Charge Distribution

    Suppose we have a neutral uncharged square current loop, carrying a constant current I. If we boost it in the x direction, x' = \gamma \left( x + \beta t \right) , so that x' increases as t increases (hence the plus sign), what happens to the current? I get that the current density in the y...
  23. mbrmbrg

    C: Simple for loop is not working

    C: Simple "for" loop is not working Homework Statement I'm taking an online course (yay lynda!) in C/C++, and I am trying to replicate a course example that prints "Hello, World!" five times, using a simple "for" loop. Homework Equations for(int i = 1; i <= 5; ++i){...} The Attempt at a...
  24. B

    Force on triangular current loop: line integrals

    Homework Statement http://pokit.org/get/img/65e8ba92c1d00bf7fc8be2b178757ed8.jpg If a=5b, and I1 and I2 are known, find the force on the triangular loop. Homework Equations The Attempt at a Solution For start, the field from the infinitely long wire is : \vec B=\large -\frac{\mu _{0}...
  25. E

    Why Does the Open Loop Transfer Function Include H(s)?

    In many books i saw that open loop transfer function is given by KG(s)H(s) , where G(s) is forward path gain and H(s) is the feedback gain. But according to the definition of open loop it does not contain feedback , then why there is a term of H(s) ? reference url...
  26. W

    Find the Total Current in a Single Loop Circuit

    Homework Statement Find the current flowing through the circuit. http://wildedge.zxq.net/IMG.jpg Homework Equations Amps=Total Voltage / Total ResistanceThe Attempt at a Solution (20 + 12 + 12 + 3) / (10 + 5 + 30 + 40 + 20 + 15)=0.39A I'm almost certain that this is wrong. I don't even know...
  27. C

    Help simple c program with loop, not running through each integer.

    Homework Statement I want to create a program that prints the sum of integers k for k(1-20) ie, k sum 1 1 2 3 3 6 4 10 5 . 6 . . . . . . 20 . in that format Homework Equations The Attempt at a Solution #include <stdio.h> int...
  28. N

    Calculating Induced EMF for a Changing Magnetic Field Loop

    1. A rectangular wire loop (length 60 cm, width 40 cm) lies completely within a perpendicular and uniform magnetic field of magnitude of 0.5 T. If the length of the loop starts increasing at a rate of 20 mm/s at time t = 0, while the width is decreasing at the same rate, what is the magnitude...
  29. T

    Relation between open loop and unity feedback close loop response

    hi! can someone please help me with this problem...i have to match the open loop respone to the close loop unity feedback system of a control system. what is the relation between the two? thanx in advance
  30. T

    Fortran FORTRAN 90 Unexpected Statement Function Statement in Nested Do Loop

    In the following code, highlighted in bold, I am using a nested DO loop to create a running sum of the yearly emissions ("emissions") read out of histem.txt, to create a cumulative emissions curve. The code generates an "Unexpected STATEMENT FUNCTION statement for sum in cem(i) = sum...
  31. T

    C/C++ [C++] Declaring an array within a loop

    The following code block is in C++ Everything is inside the first for loop. for( int i=0; i<=2; i++) { int a[3]={0}; for(int j=0; j<3; j++) a[i]=j; for( int i=0; i<=2; i++) cout<<a[i]; cout<<endl; } basically I am trying to get the screen to output...
  32. O

    Negative feedback - Open loop gain question

    This is my first post here. I'm currently learning about Negative feedback. Normally, When we want to know the open loop gain, we rewrite circuit(a) to circuit(b). My question is why do RE1,RF,RE2 from circuit(a) turn into what we see circuit(b)? what is a theory behind this? In...
  33. I

    Hand rule used to find the magnetic field in a single loop wire

    what rule hand rule shall be use in determining the direction of magnetic field in a single circular loop..pls. help me
  34. J

    Repeat the loop for a few intervals

    I am trying to find the three roots from x=0 to x=2∏ for this equation: x*Sin[x] + 1.5 x - 3. I want to divide the graph into intervals of say from x=1.0 to x=2.0 as one interval and so on and so forth. How do I go about inserting that code into my existing codes? I am using the bisection method...
  35. S

    Can Green's Theorem Simplify Calculations of Magnetic Force in Uniform Fields?

    Homework Statement Prove that, in a uniform magnetic field, the net force on a current loop carrying current I is zero.Homework Equations Green's theorem, and magnetic force equationThe Attempt at a Solution My main question is whether I can use Green's theorem to prove this result... it seems...
  36. M

    Mathematica Mathematica: Problem with For loop increments

    I'm having a recurring problem in mathematica when I try and introduce a simple for loop. For instance, I have the code shown below. It should increment my var value, and calculate a value of 'initial' for each 'var' value. These should then be recorded under the name RMPvalue[var] so I can...
  37. B

    EMF induced in solenoid by current in a loop.

    Homework Statement A square loop with side-length a is positioned at the centre of a long thin solenoid, which has radius r (with r>a), length l and N turns. The plane of the loop is perpendicular to the axis of the solenoid, find V_{emf} induced in the solenoid Homework Equations...
  38. JJBladester

    Kirchhoff's Voltage Law - Closed Loop?

    Homework Statement Determine VC for the network in Fig. 7.24 (left-hand image). Homework Equations Kirchhoff's Voltage Law: The algebraic sum of the potential rises and drops around a closed path (or closed loop) is zero. The Attempt at a Solution This is an example problem...
  39. A

    Compression force in current loop in magnetic field

    Homework Statement Please check the enclosed figure. Find the force of compression in the wire loop. Magnetic field B is directed into the page and current i is flowing anti-clockwise. The radius of the wire loop is 'a'. Homework Equations \vec{F}=i\vec{l}\times\vec{B} The...
  40. P

    Chiller Water Loop Contamination

    Hi Its an existing industrial problem. There is a chiller system and two separate Water Circulation loops are there for water flow. First: Piping of the Chiller ( Made of Copper), then Mild Steel Piping upto the storage vessel and the to plate heat exchanger (PHE). Second: Water...
  41. D

    Trying to understand ground loop in a car

    I have an mp3 player in my car and i think it is having a ground loop issue. Whenever I plug it into my cig. lighter, I could hear a whining noise. The whining noise's pitch is proportional to the engine's RPM. I'm trying to fix and understand the problem because my background is electrical...
  42. DryRun

    Finding quotient using while loop

    Suppose that the number ##\pi## is divided by 2. The resulting quotient is divided by 2 again. This process is continued till the current quotient is less than or equal to 0.01. What is the largest quotient that is greater than 0.01? Here is my attempt: r = 1; quo = 1; while (quo > 0.01)...
  43. H

    Designing a closed loop fluid system

    Homework Statement I'm doing a project right now which deals with designing a closed loop recirculating system using water to cool multiple components. However, this post will only deal with the fluids portion. Below is the diagram of a very simplified system. Note that the areas marked red...
  44. Z

    Vector displacement around a closed loop

    My book says that the total vector displacement around a closed loop is zero. Is this a general thing for every type of closed loop? If so, should this be obvious?
  45. C

    Ziegler-Nichols method and closed loop characteristic equations.

    Hi Guys, Attached is a problem from an old exam for a Process Control and Instrumentation unit. I have tried everything I know (which isn't much, it's not the main assessable portion of the unit). Other questions similar involve giving us either the characteristic closed loop equation...
  46. M

    Assembly Language: How to make a loop skip the first line?

    Hello, so i have a problem with my assembly code. I want to clear the screen of the DOS and display the string input in the first line. I decided to make a loop that will run 2000 times and fill the space with [20H, which is the ascii for space bar] however, It clears out my message as well and...
  47. R

    Emf of a Closed Loop of Wire In a Magnetic Field

    ]Homework Statement A closed loop of wire 7.2 x10^{}-3 m^{}2 is placed so that it is at an angle of 60degrees to a uniform magnetic field. The flux density is changing at 0.1 T/s. The emf, in V, induced in the loop of wire is A) 3.6x10^{}-4 b)3.6x10^{}-2 6.9 Homework Equations emf...
  48. 5

    Magnetic field lines in a current carrying circular loop

    I wanted to ask that do each point of the current-carrying circular loop would create a magnetic field and hence the magnetic field lines? And if yes wouldn't the field lines produced by each point of the loop would intersect each other? I read somewhere that magnetic field lines never...
  49. N

    Explaination of Quantum Loop Gravity?

    Can anyone here explain to me how does quantum loop gravity works?
  50. D

    Nested if statement within a do-while loop

    I don't understand why this would work, shouldn't it be "while(x)" because we don't want to repeat the loop? int main(void) { int x=0; do { printf("Enter an amount:\n"); scanf("%lf", &amount); if (amount < 100) x=1; else printf("Invalid"); }while(!x); return 0; }
Back
Top