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

    MATLAB Arduino-MATLAB communication using SerialEvent() for PID Loop

    Hello, I have an arduino code for driving a peltier pile to a given set point (TEMP_SP). I am trying to input the set temperature from Matlab GUI (with different protocols, user will enter n temperatures and the time intervals, arduino will implement the PID controller and output the...
  2. Kanashii

    Finding the second derivative using central difference formula

    Homework Statement Develop aprogram that will determine the second derivative of pi(16 x^2 - y^4) at y=2 with step sizes of 0.1, 0.01, 0.001…. until the absolute error (numerical-analytical) converges to 0.00001. Use the 2nd order Central Difference Formula. User Input: y, tolerance Output: h...
  3. moenste

    Energy dissipated in the loop during mag. field change

    Homework Statement A closed wire loop in the form of a square of side 4.0 cm is mounted with its plane horizontal. The loop has a resistance of 2.0 * 10-3 Ω, and negligible self inductance. The loop is situated in a magnetic field of strength 0.70 T directed vertically downwards. When the field...
  4. L

    Minimum Speed for a Roller-Coaster Car to Complete a Loop without Seat Belts

    In an amusement park, the new roller-coaster ride The Loopy Looper is com- posed of a number of full loops, where the car goes round upside down. The car is attached to the track, but there are no seat belts. Consider one such loop, which can be taken as a circle with radius r. The mass of the...
  5. moenste

    What is the current induced in a wire loop placed in a changing magnetic field?

    Homework Statement A closed wire loop in the form of a square of side 4 cm is placed with its plane perpendicular to a uniform magnetic field, which is increasing at the rate of 0.3 T s-1. The loop has negligible inductance, and a resistance of 2 * 10-3 Ω. Calculate the current induced in the...
  6. Pao44445

    Finding Voltage Using Junction & Loop Rules

    Homework Statement find the voltage between a and d and terminal of each batteries Homework Equations Junction Rule and Loop Rule The Attempt at a Solution I got three equation JR : I3 = I1+I2 LR : 45-I3-47I3-34I1 = 0 45-I3-47I3+85-I2-18I2 = 0 I can't solve these...
  7. FelixTheWhale

    Magnetic Field of Current loop around the Core

    Hello friends, I am trying to find how calculate the magnetic field created by current loop considering that there is a some geometry of material that can enhance the magnetic field. I thought it can be solved by multipling by permeability μ but realized that the iron core changes the picture of...
  8. JustinT

    A different type of roller coaster loop problem

    Homework Statement A roller coaster at the nearby amusement park Physics Hill, has a large circular loop where cars travel at the top of the loop at 25.0 m/s causing the riders to enjoy an acceleration of 3g. Assuming the height of this loop is the same as the diameter, how high is the loop...
  9. jiaying

    MATLAB Matlab -- how can i use a FOR loop if I have 2 variables changing

    Hey,for following code the 3rd loops i need to have 2 variables m and q .Could anyone help? for t=1:maxiterations toterror=0; for j=1:numfeature totslope=0; for i=1:m&&q=1:numfeature z=0; for jj=1:numfeature...
  10. moenste

    The balance reading when direction of mag. field changes

    Homework Statement The diagram shows a rigid conducting wire loop connected to a 6.0 V battery through a 6.0 V, 3.0 W lamp. The circuit is standing on a top-pan balance. A uniform horizontal magnetic field of strength 50 mT acts at right angles to the straight top part of the conducting wire in...
  11. K

    I Tensor networks, spin networks and loop quantum gravity

    Loop Quantum Gravity, Exact Holographic Mapping, and Holographic Entanglement Entropy Muxin Han, Ling-Yan Hung (Submitted on 7 Oct 2016) The relation between Loop Quantum Gravity (LQG) and tensor network is explored from the perspectives of bulk-boundary duality and holographic entanglement...
  12. A

    Centripetal Force, Friction, Loop de Loop, and Normal Forces

    Two questions I had: 1. How is the force of friction of the tires pointed inwards to cause centripetal acceleration? If the tire is rotated when trying to turn, the car is still traveling with a velocity perpendicular to the circle and force of friction would still be counteracting the...
  13. M

    Engineering Solving Circuits with Resistors: Finding Req and Applying the VIR Chart

    Homework Statement https://s10.postimg.org/lb6n94ua1/20161007_190700.jpg Homework Equations V=IR The Attempt at a Solution So far I haven't had any problems finding the Req. However, I am having trouble with the VIR chart. Can anyone confirm whether or not I did it correctly. My thought...
  14. A

    I Spin Foam models in Loop Quantum Gravity

    Hi all, I fairly basic question about spin foam models in loop quantum gravity. I just want to verify that spin foams represent effectively represent all of spacetime (in a quantum form), and that the idea is that general relativity can be obtained in the classical limit? Not sure if that's...
  15. R

    Falling loop in magnetic field

    Homework Statement This is a question regarding Problem 7.11 in Griffiths Electromagnetism book, which considers a falling square loop of aluminum through a uniform magnetic field pointing into the page with only part of the loop in the field at t=0 (see picture below). To solve this...
  16. M

    Polarization-electric field hysteresis loop of a piezoelectric film.

    Hello, I have piezoelectric film. I want to characterize ferroectricity. which exact equipment and circuit are used for measuring polarization-electric field hysteresis loop. Thanks
  17. moenste

    Ball speed at the top of the loop

    Homework Statement A compressed spring is used to propel a ball-bearing along a track which contains a circular loop of radius 0.10 m in a vertical plane. The spring obeys Hooke's law and requires a force of 0.20 N to compress it to 1.00 mm. (a) The spring is compressed by 30 mm. Calculate...
  18. A

    Moving a loop within a changing magnetic field

    Hello, Short description: In my country's physics olympics, if a loop of wire is moved in a changing magnetic field, the time derivative of the area (while calculating emf with lenz law) is the velocity of the loop (as if we're taking the time derivative of the AREA SWEPT). This has became an...
  19. A

    Magnetic field due to a current carrying loop

    Homework Statement The actual question was to somehow derive the expression for a magnetic field at the center of a current carrying loop. Homework Equations The Biot-Savart's law equation dB = (mu/4π)*(i dl x r)/r^3 (I'm not actually good at typing in the equations, so please just forgive...
  20. G

    Calculating Induced EMF in a Bent Loop with Changing Magnetic Field

    Homework Statement The figure below shows a closed loop of wire that consists of a pair of equal semicircles, of radius 7.0 cm, lying in mutually perpendicular planes. The loop was formed by folding a flat circular loop along a diameter until the two halves became perpendicular to each other...
  21. J

    I Loop Quantum Gravity and Virtual Particles....

    Hi all, Following up on another post - for a layman, can someone describe the status of virtual particles in Loop Quantum Gravity models? Since LQG avoid UV divergences, and has a different structure from field-based theories, are virtual particles still talked about? (in the context of closed...
  22. KonaGorrila

    MATLAB How to get the last variable of a for loop in MATLAB

    Aloha guys, I am just having trouble getting MatLab to output only the last variable of my "for loop." If anyone can help all I am looking for is an example of notation. p.s. I have done this before just not in a while and will continue to look through my old scripts and functions. just not in...
  23. Marcin H

    Loop Current Method/Loop Analysis Confusion

    Homework Statement Homework Equations Loob Analysis V=IR The Attempt at a Solution So I think I have the right equation here, but I am a bit confused on some parts. I am not too sure why i2=i1-ix. The way my professor explains it doesn't make much sense. Also (TYPO) in the second...
  24. K

    I Can Loop Quntuam gravity be merged with Asymptotic safety

    can Loop Quntuam gravity be merged with Asymptotic safety scenario in gravity into a single theory of QG, one that has both concepts ? i.e if you start with Loop Quntuam gravity in 4D, can you show that it is also implies Asymptotic safety scenario in gravity in 4D? are there any papers...
  25. T

    Does a Magnetic Moment μ exist for any closed current loop?

    I'm asking the above question as I imagined a current loop made out of a curving wire that cannot fit into a flat plane. Where does the direction of μ point then? Also, is there only one μ value for any current loop, independent of the chosen axis of tilting? Or can a current loop have...
  26. wolram

    B Why Quantum loop or string theory

    I was wondering why Quantum loop theory is still being followed FAIK it does not predict any thing yet, the same for string theory which seems to have lost its predictability, if these theories fail being tested where will we be It seems to me like super symmetry is the theory that every one...
  27. E

    MATLAB What is wrong with this WHILE loop?

    Here is my code: while a ~= 3 || b <= 1; a = a - 1; (other expressions); end; For this code, the 'while' loop should stop when 'a' reaches 3, however it does not, even though 'a' starts with a higher value than 3. The 'other expressions' part are calculations that manipulate 'b', the only...
  28. C

    Solving a Physics Problem: Find Velocity of Block at Bottom of Loop

    Homework Statement This is for my ap physics summer work and is giving me some trouble and could use any help A small block, with a mass of 250 g, starts from restart the top of the apparatus shown above. It then slides without friction down the incline, around the loop then onto the final...
  29. C

    Understanding the Use of '==' in While Loops: Explanation and Example

    Homework Statement for teh circled part , why there's again =='y' ? i didnt see the variable 'y' anywhere other than the circled part ...What does it mean ? Homework EquationsThe Attempt at a Solution Is the code wrong ?
  30. ShayanJ

    A Vertex, Propagator and Loop counting

    I'm reading these lecture notes but there is something I don't understand. In page 15, it starts to consider vacuum diagrams of various orders and tries to associated a factor to them according to the rule: ## diagram \sim (\frac \lambda N)^p(\frac N \lambda)^v N^l=\lambda^{p-v} N^{l+v-p}##...
  31. M

    Determining the Poynting Vector for Loop Antennas

    So I came across the following image (from Wikipedia) where the electric and magnetic field lines are depicted for a dipole antenna. From the field lines, it is possible to determine the direction of the poynting vector, using the right-hand rule. If all possible combinations of poynting...
  32. Larry Gopnik

    MATLAB Updating variables as they go through a loop

    Hi all, This might be a simple question but I cannot seem to find any solution online I'm currently building a MatLab code for my project which involves in the ageing of certain artefacts and paintings, I've got most of it built but can't solve the simplest of problems of the start of the...
  33. M

    Determining the force on a loop cause by an infinite line

    Homework Statement An infinitely long line of current $I_1=6[A]$ is following along the positive z-axis in the direction of +$\hat{a_z}$. Another current is following a triangular loop counter clockwise from the points A(0,2,2), B(0,6,2) and C(0,6,6). Homework Equations To start I applied...
  34. J

    Circular loop in magnetic field

    Homework Statement A circular single loop of wire with a diameter of 20.0 cm lies in the plane of the paper in a region of space that contains a 1.75 T magnetic field pointing out of the paper. a) Determine the magnetic flux through this loop. b) If the diameter of the loop changes from 20.0...
  35. M

    Mathematica "Do" loop with "If" conditional

    Hi, I have a function defined by: F[x_,y_,z_]:=3 x+y-2Y[z] where Y[z_]:=3/z I'd like to run Do loop to calculate the value of this function for specific regions of x,y,z. I can use: Do[F[x,y,z],{x,1,2,1},{y,-2,-1,1},{z,3,5,1}], But I have two questions here: First: How to save the output...
  36. wrobel

    A Finding Equilibriums on a Cone with a Chain Loop

    Imagine a right circular cone with smooth surface. The cone is stated such that its axis is parallel to the standard gravitational field g. And you have a piece a thin homogeneous chain. Then you connect the tips of the chain to obtain a loop. You put this loop on the cone: It is clear...
  37. J

    Does AC form a closed loop circuit?

    Some say that AC should form a closed loop circuit for electricity utilization but is there really an loop from the Power station(hot wire) to the Ground(neutral) and then from Ground to power station so that it forms a loop?
  38. P

    Find the electrostatic potential above loop of charge Q?

    Homework Statement An electric charge Q is uniformly distributed along a thin circular wire situated in the z = 0 plane at x2 + y2 = R2 . Determine the electrostatic potential at the point (0, 0, D). Homework EquationsThe Attempt at a Solution I figured the only components that mattered would...
  39. Biker

    Magnetic fields in circular loop

    If I have a some a wire and I took part of it and created a circle. If I want to calculate the strength of the magnetic field at the center of it. I should just use the magnetic field equation for the circular loop, shouldn't I? ## B = \frac{U_o N I}{2R} ## and I shouldn't care about the...
  40. T

    MHB PrintShampooInstructions(): Function for Looping Cycles

    Write a function PrintShampooInstructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N: Lather and rinse." numCycles times, where N is the cycle number, followed by "Done.". End with a...
  41. S

    B Using center of mass for loop de loop

    A quick question, I remember my professor said to use the center of mass for solving the classic loop de loop problem. For example, he wanted us to use the distance from the surface of the loop to the center of the object (instead of just from the loop to the surface of the block) for the height...
  42. S

    Magnetic field change for induced current

    Homework Statement A uniform magnetic field is perpendicular to the plane of a circular loop of diameter 10 cm formed from wire of diameter 2.5 mm and resistivity 8.5×10-8 Ω·m. At what rate must the magnitude of the magnetic field change to induce a 10 A current in the loop? Homework Equations...
  43. S

    Magnetic field strength for circular loop

    When deriving the magnetic field strength due to a circular loop at some distance away from it's center (using Biot-Savart's law), why is the angle between ds and r 90 degrees? This is a youtube video with the derivation, see 5:55
  44. gsmtiger18

    Displacement current and magnetic flux through a wire loop

    Homework Statement A long straight wire has a line charge, λ that varies in time according to: λ = λ0e(-βt). A square loop of dimension, a, is adjacent to the wire (at a distance a away from the wire). Calculate expressions for the displacement current at the center of the wire loop and the...
  45. S

    Biot-Savart's Law for cylindrical conductor

    Homework Statement The figure shows a cross section across a diameter of a long cylindrical conductor of radius a = 2.92 cm carrying uniform current 151 A. What is the magnitude of the current's magnetic field at the center of the conductor? Homework Equations Biot-Savart's Law The Attempt...
  46. A

    EMF about a loop moving toward a wire with current

    Homework Statement A picture of a related problem is attached below. My problem is the same, except that v is toward the wire, not away from it. I, r, v, b and a are given. "Find the emf about the loop without assuming that B changes at any point" My problem is that this question isn't...
  47. S

    Radiation from a Square Loop of Current

    It is well known that a circular loop of steady current does not radiate, even though each individual charge is undergoing centripetal acceleration. How about a loop of steady current that is shaped in a square? Does this structure radiate?
  48. Toughnuke

    Electromotive force (EMF) of a circular loop wire

    Hi, so, I got help from this homework problem by posting it on chegg, but I want clarification. A circular loop of wire of radius 12.0 cm is placed in a magnetic field directed perpendicular to the plane of the loop and into the page. The field is decreasing at a constant rate of 0.050 T per...
  49. E

    The magnetic field induced by a current loop

    A square loop of wire in the x-y plane, centred on the origin, is made up of four straight segments, each of length 2d=10cm. A current I =10A flows in the wire in the direction shown. Find the magnetic field at z=d on the z-axis. (See "Diagram" for the diagram of the problem) Here is the...
Back
Top