What is Loop: Definition and 1000 Discussions

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. Q

    Magnetic field of circular loop

    Homework Statement Two small identical circular loops carrying equal currents are placed with the geometrical axis perpendicular to each other. Find the magnitude and direction at a point O at an equal distance x from their centers. Homework Equations Magnetic field of a current carrying...
  2. E

    MATLAB Solving MATLAB For Loop Error: Counting 'c' to 11

    For loop in Matlab I have written following code in MATLAB but the if condition inside the for loop isn't working properly. Can anyone tell what's the possible bug?? f=1000; T=0.001; g=0:0.00005:5; w=2*f*T*pi; s=sin(g*w); plot(g,s); grid on; title('SINE FN'); xlabel(' x10^-3 TIME...
  3. P

    Friction problem with loop (work and energy)

    Hello, i appreciate your help! 1. Homework Statement In this website the drawing of the situation in the first exercise can be seen, for better understanding. http://wwwprof.uniandes.edu.co/~gtel...s-semana10.pdf The problem asks me to determine the minimum height h to allow an...
  4. P

    Non conservative energies on a Loop

    Hello, i appreciate your help! Homework Statement In this website the drawing of the situation in the first exercise can be seen, for better understanding. http://wwwprof.uniandes.edu.co/~gtellez/fisica1/ejercicios-semana10.pdf The problem asks me to determine the minimum height h to allow...
  5. E

    Help setting up Loop Analysis

    Homework Statement http://i.imgur.com/pVIMw.png Homework Equations KVL The Attempt at a Solution I called the top left loop i1, the top right loop i2, the bottom right loop i3, and the bottom left loop i4. I have all of these currents going clockwise in my work. An attempt to do loop...
  6. E

    Find voltage across a resistor using Loop Analysis

    Homework Statement http://i.imgur.com/H20el.png Homework Equations KVL The Attempt at a Solution When I solved the equation for V0, I got V0=2V. Is this correct? If it's not, I'll upload my work. Thanks!
  7. N

    MATLAB How to plot multiple iterations of a while loop on one plot? [MATLAB]

    If I want to plot multiple iterations of a while loop on one plot, how can I do that? Every time I use "hold on", it just distorts the original line after every iteration instead of drawing independent lines. Please help
  8. N

    Simple While Loop Problem [MATLAB]

    Homework Statement Write a script using a while loop that calculates the number of years it will take your bank account to accumulate at least $100,000 if you begin with s number of dollars, and you add that same amount at the end of each year. In addition, your account pays a percentage of...
  9. N

    Did I do my loop analysis correctly?

    Homework Statement Homework Equations The Attempt at a Solution If we were to call the bottom right loop I1, the top loop I2, and the bottom right loop I3. I got the following: I1 = 1mA I2 = 6mA I3 = 2mA Which gives me a final answer of I0 = -1mA. Is this correct?
  10. S

    Newton's Method for Root Finding - Infinite Loop

    1. Construct a function f (x) so that Newton's method gets 'hanging' in an infinite cycle xn = (-1)n x0 , no matter how the start value x0 is chosen. 2. Homework Equations : xn+1 = xn - f(xn) / f'(xn) The Attempt at a Solution xn+1 = xn - f(xn) / f'(xn) = (-1)n+1x0 = (-1)nx0 -...
  11. C

    Calculating ratio energy radiated in a loop and comment on result

    Homework Statement Designers of electrical circuits often take the maximum amplitude of the radiated electric field (at a large distance r) produced by an alternating current I0 flowing in a loop of area A cm2 to be given by E=\frac{2.6AI0f2}{r}\muVm-1 where f is the frequency in MHz...
  12. C

    Searching for quantum loop gravity groups

    I'm searching for research groups of quantum loop gravity, Does anyone can help me to find at least one of them?. I want to do my PhD on that topic and I have found kind of hard to find those groups and I am looking for a good supervisor, any reference would be very very helpful. Thanks...
  13. H

    Loop the Loop (Conservative Forces and Potential Energy)

    Homework Statement A mass m = 71 kg slides on a frictionless track that has a drop, followed by a loop-the-loop with radius R = 16.1 m and finally a flat straight section at the same height as the center of the loop (16.1 m off the ground). Since the mass would not make it around the loop if...
  14. L

    How did I capture these intriguing feedback loop photos?

    Feedback loops can be very cheap and can be modified easily by things to produce some interesting photos. I used the attached setup to capture these images over 12 years ago and they are accurate to what you actually see on the screen within the maxed out limits of the hardware/software...
  15. reddvoid

    Why open loop transfer function ?

    I don't understand why always we use open loop transfer function G(s)H(s) to draw the root locus. can somebody please clarify my doubt. Thanks in advance.
  16. D

    What is the solution to this circuit problem involving Kirchoff's Laws?

    Homework Statement The circuit in the figure is composed of two batteries (ε1 = 8 V and ε2 = 5 V) and four resistors (R1 = 110 Ω, R2 = 40 Ω, R3 = 50 Ω, and R4 = 50 Ω) as shown. Image: See Attachment OR: https://smart.physics.illinois.edu/images/phys102/Homework/03/cir06.gif Homework...
  17. tom.stoer

    Thiemann on the relation between canonical and covariant loop quantum gravity

    http://arxiv.org/abs/1109.1290 [B]Linking covariant and canonical LQG: new solutions to the Euclidean Scalar Constraint[/B Authors: Emanuele Alesci, Thomas Thiemann, Antonia Zipfel (Submitted on 6 Sep 2011) Abstract: It is often emphasized that spin-foam models could realize a projection on...
  18. S

    Understand Fortran Coding Do Loop: VBA Translation Help

    Can some1 kindly help me understand the following code, I am trying to translate the following code in VBA: Thanks in advance FFLC = FLC ...i understand this part ANGLE=PI/6 !Suppose 30 Degrees ...i understand this part Do 21800 I=i,5 ...Don't understand this FLC=FFLC-COS(ANGLE)*NDIA...
  19. marcus

    Why would a Susy signal have been bad news for the Loop program?

    This may seem like a naive question to some people. I had always heard that Lqg can easily incorporate supersymmetry---that if there were any evidence of it, putting it into the theory would be straightforward. This goes way back, to papers I read in 2003-2005. Not sure exactly which, but it...
  20. N

    Inductive Loop Detectors at Hight Vehicle Speed

    Hello Everyone I am currently studying the inductive loop detectors used in the traffic control department. I believe the data from the detectors is highly unreliable and noisy. A lot of research has been going on on the 'Fault detecting algorithm' and other means to improve the accuracy of...
  21. C

    The end of String Theory and Loop Quantum Gravity ?

    If spacetime is composed of tiny quantum "grains," the gamma-ray photons' polarization should change from random polarization (at the GRB source) to biased toward a certain polarization when received by the Integral spacecraft . The Integral polarization results depend on spacetime being...
  22. M

    Height of ramp given normal force in circular loop

    Homework Statement The attachment shows the problem. The normal force at the top of the loop is 3 g's (as in g-force). Homework Equations PE = mgh KE = .5mv2 Fc = \frac{mv2}{r} PE + KE = PE' + KE' v = \sqrt{2gh} The Attempt at a Solution The normal force would be: 30 * mass...
  23. L

    Line of action of force in torque experienced by a current loop

    Homework Statement Please see my attachment Homework Equations In the diagram, F1 and F2 are equal and opposite also F3 and F4 also equal and opposite. Its been mentioned that F1 and F2 have same line of action of force and the resultant effect on the loop is zero. But F2 and F4...
  24. L

    Torque experienced by a current loop in uniform magnetic field

    Homework Statement Revered members, please see my attachment (1) In this diagram, PQRS is a rectangular current loop and I is the current and its direction is shown in red arrow . B is the magnetic field and it acts from left to right and n is the normal drawn to the plane of the loop...
  25. F

    Why does my microphone hum change when I touch different objects?

    Noticed something interesting about my microphone today and can't stop thinking about it. So there's always been this humming noise with my microphone (I can clearly hear it since I am using headphones), but I've never really thought about it. Now suddenly today my foot touched the metal casing...
  26. A

    Magnetic field of current loop

    Homework Statement Find magnetic field along the z-axis of a circular loop, radius R with constant current lying in the z=0 plane. Homework Equations vec(r) = vector of r. zhat = unit vector z. The Attempt at a Solution So starting with the definition, B = (u_o I/4pi) (dl x...
  27. M

    Loop variables for string theory

    "Loop variables for string theory" That is the title of a http://arxiv.org/abs/hep-th/0207098" . I know quite a few people have wondered what string theory would look like in the framework of loop quantum gravity. Well, this is a glimpse of how it would be. Only a glimpse, because no-one...
  28. B

    Loop contributions of the Quantum Action

    As far as I understand the tree level diagrams of the quantum action in QFT give the complete set of diagrams for a give process. Do the loop diagrams of the quantum action have any physical significance? I thought maybe that by summing up all the diagrams in the quantum action might take us...
  29. M

    Refrigeration Loop: Pressure Measurements and Corresponding Components

    Homework Statement I have just done a lab with a refrigeration loop, and I'm unsure of which pressures correspond to which parts of the loop. The hand out says to assume the pressure across the condenser and evaporator are constant, and to use the two pressure guages to measure the pressure...
  30. H

    Unsteady flow code - Problem with space loop

    Hi all, I have discretized my equations in a way that for example the velocity depends on the velocity of the previous neighboring element so: h = number of elements t = 0: 0.5 : 10 for j= 1 : length(t) for i = 2: h v(i,j) = v(i-1,j) + b p(i,j) = p(i,j) +b end end This is not my...
  31. I

    Estimate the magnitude of the torque the large loop exerts on the smaller one.

    Homework Statement A small loop of wire of radius 1.5 cm is placed at the center of a wire loop with radius 20 cm. The planes of the loops are perpendicular to each other, and a 5.0 -A current flows in each. Estimate the magnitude of the torque the large loop exerts on the smaller one...
  32. I

    Determine the magnitude of the net force on the loop.

    Homework Statement A rectangular loop wire is placed next to a straight wire, as shown in the figure. There is a current of 3.5 A in both wire. Figure: http://www.flickr.com/photos/65980314@N06/6020832477/ Homework Equations F = ((mu(0)*I1*I2) / (2*pi*r)) * L force in terms of...
  33. P

    Creating a 'For' Loop to Calculate Answers for Sets of 11 Values

    I have a 5000x1 vector and am trying to write a function to calculate an answer for entry 1-11, then 12-22, then 23-33, etc. ... I've been trying to use a 'for' loop, basically: for i = (??) x=i+1 end Not sure what to put in the ? area. I want it to spit out answers for each set of...
  34. wolram

    Loop quantum cosmology status report

    Sorry if this has already been discussed, i couldn't find any thing.arXiv:1108.0893 (cross-list from gr-qc) [pdf, ps, other] Loop Quantum Cosmology: A Status Report Abhay Ashtekar, Parampreet Singh Comments: 136 pages, 15 figures Subjects: General Relativity and Quantum Cosmology...
  35. R

    Electric field of a loop with one positive halve and one negative halve

    Homework Statement Given a circular wire with radius R. Choose the origin in the center of the circle, the z-axis perpendicular to the circle. One halve of the circle contains a positive line charge \lambda, the other halve a negative line charge of the same magnitude. (a) Sketch the electric...
  36. R

    How does an rotating loop determine direction of an station signal

    Considering the ADF (automatic direction finding) of an aircraft. Assuming the transmitting aerial is vertically polarised i.e mag field lies in the horizontal plane. And it is the magnetic field of the incoming signal that induces current in the loop. And what would be the rotating plane of...
  37. wolram

    Testing loop quntum cosmology

    arXiv:1108.0079 [pdf, ps, other] Gravitational wave generation in loop quantum cosmology Paulo M. Sá, Alfredo B. Henriques Comments: 7 pages, 8 figures, revtex4 Subjects: General Relativity and Quantum Cosmology (gr-qc) We calculate the full spectrum, as observed...
  38. A

    Finding Moment of Interia of a 'Loop' when given Density & Cross sectional area

    Homework Statement I eventually have to solve for maximum angular acceleration of the loop in a magnetic field, and I have gotten everything with the exception of the moment of inertia, so I won't include the emf and B known variables. Known: a copper wire with a density of \rho = 8960...
  39. P

    Finding the magnitude of a magnetic field from a square loop

    Homework Statement A square loop, with sides of length L, carries current i. Find the magnitude of the magnetic field from the loop at the center of the loop, as a function of i and L. (Use any variable or symbol stated above along with the following as necessary: μ0.) Homework Equations...
  40. W

    Problem with For Loop - Any Help Appreciated

    Hi all, Im having a problem with the for loop. Any help would be great! The code is simple, x = -3:0.5:3; For i = x q(i) = i^2; end q The error seems to be the negative index in the statement of the for loop. Hope this is clear. Thanks!
  41. 0

    What is the Magnetic Field at the Center of a Square Loop Carrying a Current?

    Homework Statement A conductor in the shape of a square of edge length 0.28 m carries a current I = 17.0A. Calculate the magnitude of the magnetic field at the center of the square. Round your answer to three significant figures. Take the permeability of free space to be 4*pi*10^-7...
  42. Jim Kata

    Figuring out higher loop corrections

    Let's say I'm trying to calculate the vacuum polarization to the two loop level for QED, how do I do that from a path integral formalism? As in how do I know which Feynman diagrams to calculate? I would have a path integral like this. - i\Delta _{\mu x,\tau y} = \left\langle {T\{ A_\mu...
  43. L

    What is the role of RC in opamp feedback loop for Type 2 opamp compensators?

    I am trying to understand Type1, 2 and 3 opamp compensators used in DCDC converters. Type 1 is just an opamp integrator. Type 2 has a C in feedback loop with parallel RC. How does this boost the phase Margin? (page 307 - http://tinyurl.com/3qyt5dc) I understand phase and gain margin when...
  44. F

    MATLAB Help with ODE45 and Plotting in MATLAB Loop

    Hey i need help in ODE45...i'm new to PF...pls help me i have the following code >>for i=1:5 >>tspan=[0 30] >>h0=Hv(i) >>[t,h]=ode45['a ODEfunction',tspan,h0] >>plot(t,h) >>end in this loop how can i save 5 values of [t,h], as t, h produces each loop run like follows t= 1 2 3...
  45. S

    How does a 'open surface' of a closed loop look like?

    im on the topic of electricity and magnetism, and came across walter lewin's lecture. i cannot visualise how the 'open surface' of this solenoid will look like is the open surface a riemann surface? or something else...
  46. R

    EMF in loop, given magnetic field

    Homework Statement In the figure below, a circular loop of wire 12 cm in diameter (seen edge on) is placed with its normal at an angle θ = 30° with the direction of a uniform magnetic field B of magnitude 0.60 T. The loop is then rotated so that N rotates in a cone about the field direction...
  47. G

    Another Noob MATLAB Question - For loop

    Homework Statement Use the primes function to create a list of all the primes below 100. Now use a for loop to multiply adjacent values together. For example the first 4 primes numbers are 2 3 5 7 your calculation would be 2*3 3*5 5*7 which gives 6 15 35 Homework...
  48. jaumzaum

    How Long Does It Take to Complete a Loop on a Rollercoaster with Friction?

    Calculate the time t to complete a loop of a rollercoaster of radius R by a car that has initial velocity Vo, with friction u. We can calculate the velcity V if we have alpha, the angle that the car is in the rollercoaster acceleration in alpha = g.sen alpha - acceleration by atrictFc=N+g.cos...
  49. R

    Calculating current in a loop, given torque and magn. field

    Homework Statement In the figure below, a rectangular loop carrying current lies in the plane of a uniform magnetic field of magnitude 0.038 T. The loop consists of a single turn of flexible conducting wire that is wrapped around a flexible mount such that the dimensions of the rectangle can...
Back
Top