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

    PhD on Loop Quantum Gravity (at UK): What's the best option?

    Hello guys! I hope that you could help me. I want to do my PhD on LQG at the UK and I have the following options: Newcastle, with David Toms. (His research area is QFT on curved spacetime but he liked my project on LQG) Aberdeen, with Charles Wang Nottingham, with Kirill Krasnov or John...
  2. S

    Need Help with a Triangular Loop Problem?

    This is a question I got wrong on a test and would like to see if I can get someone to show me how to do it properly. Snapped a pic . See below please. Thanks.
  3. O

    Lenz's Law for a Rotating Loop

    Homework Statement A copper wire loop is initially at rest in a uniform magnetic field (full flux going through it). Between times t=t1 and t=t1+(delta)t the loop is rotated about a vertical axis as shown (no flux going through it). Will current flow through the wire of the loop during this...
  4. C

    Find the area of the loop using Green's Theorem

    Homework Statement Problem in attachment. Homework Equations The Attempt at a Solution Unfortunately I was unable to attend my only class where my proffessor taught this method of solving area. Plus my prof and classmates won't help me. Does anybody know how to solve area...
  5. 2

    Controlled system - Closed loop system

    I have this assignment (First problem - exercise 2 - dias 7) http://site.iugaza.edu.ps/bhamed/files/2010/02/L4-Root-Locus.ppt Which i am having some problems solving. I am stuck at B) So far i tried to solve the problem, by calculating the distance from origin to the breakaway point, by...
  6. LydiaAC

    Approximate inductance of a filamentary circular current loop

    Hello everyone, I want to have a simple example of an inductance calculation. The magnetic field normal to a filamentary circular current loop is not constant over the circle but if we approximate the value as that for the center, multiply by the area of the circle and divide by the current...
  7. L

    Minimum Radius for 2.4GHz RC Car Loop Experiment

    I need a general rule of thumb or simple formula to determine the minimum radiius required for an experiment. I have a 2.4GHz remote control car that reaches about 45 mph. If I begin at a certain distance from the loop at ground level, how large will that loop need to be? The car measures 19"...
  8. binbagsss

    EM , magnetic field at centre of a carrying circular loop

    The question is to find the magnetic field at the centre of a current carrying circular loop of radius R, where the current = I Okay so I'm trying to do this by both Amp's Law and Biot Savarts Law, and I can't get my answers to agree. First method - Biot Savarts Law...
  9. L

    EMF in a square loop due to magnetic field from an infinite wire

    Homework Statement Determine the emf induced in the square loop in the figure if the loop stays at rest and the current in the straight wire is given by I(t)=(15.0A)sin(2500t) where t is in seconds. The distance a is 12.0 cm, and b is 15.0 cm. Homework Equations emf = Δmagneticflux/Δt...
  10. S

    How Do You Calculate the Magnetic Field Above a Current-Carrying Loop?

    Homework Statement Calculate the magnetic field above a loop shown in picture with radius ##R## and current ##I##.Homework Equations The Attempt at a Solution Firstly, curved part: ##\vec{H}(\vec{r})=\frac{I}{4\pi }\int \frac{d\vec{{r}'}\times...
  11. N

    Induced EMF in metal loop near RC circuit

    Homework Statement (Challenge Problem 80, Ch33) A rectangular metal loop with 0.050 ohms resistance is placed next to one wire of the RC circuit shown in the below figure. The capacitor is charged to 20 V with the polarity shown, then the switch is closed at t = 0s...
  12. Y

    MHB How the charge is conserved in a closed loop circuit?

    How the charge is conserved in a closed loop circuit?
  13. K

    Expression for current through loop as a function of time

    Homework Statement An N-turn circular coil of radius r with a total resistance of R is placed such that the normal to its plane is parallel to the +z axis. A uniform magnetic field varies with time according to B=B0sin(\omegat) where the amplitude B0 and angular frequency ω are constants...
  14. H

    Infinitely Long Wire with Loop (Magnetic Field)

    Homework Statement The wires below are infinitely long and some of them are with loops and semi loops. The current I is constant. What is the magnetic field in point O, when R is the distance from it? Questions: In F, E and H, the magnetic field exerted by the terminal infinitely long...
  15. B

    Relationship between Induced Current and Current in a Wire

    Homework Statement A long straight wire carries a steady current. A square conducting loop is in the same plane as the wire. If we push the loop toward the wire, how is the direction of the current induced in the loop related to the direction of the current in the wire? Homework...
  16. S

    MHB Finding the area inside of a loop

    I know this is relatively easy but I'm just confused on the process... Find the area inside one loop of a four leafed rose r = cos(2\theta). I know that the formula is A = \int ^{\beta}_{\alpha} \frac{1}{2} [f(\theta)]^2 right? I'm just not sure what to plug in or solve for.
  17. F

    What is the Force on a Rectangular Loop in a Magnetic Field?

    Homework Statement Let d = 0.048m, L = 0.15m, r = 0.10m in the following diagram. Assume that the current I1 = 80.0A and I2 = 40.0A. Find the net force on the rectangle of wire and the direction it points, and state the direction of the emf if the current I1 is increasing in the direction of...
  18. E

    Vector potential components in small loop antenna

    Consider a small, thin loop in the (x,y) plane centered in the origin and with radius a. We are interested in the vector potential \mathbf{A} generated by the loop at a point P(r, \theta, \phi), with 2 \pi a \ll r, so at a great distance (moreover, a \ll \lambda). We need two coordinates...
  19. H

    Isolating a variable gives me endless loop

    Coming in here with the following question, when I see what kind of stuff you normally tackle, is very embarrassing! But... I simply am too rusty for this stuff, it seems. This is NOT homework. This is something I need to do in a game I'm working on. I end up in and endless loop when trying...
  20. J

    Do you have a device in your home that uses a control loop?

    What is it controlling and What devices are in the loop
  21. marcus

    Length and curvature operators in Loop gravity

    Most of us are familiar with the fact that in Loop gravity the area and volume observables have discrete spectrum. The discrete spectrum of the area operator, leading to a smallest positive measurable area, has lots of mathematical consequences that have been derived in the theory. It helps...
  22. T

    Magnetic Field at Center of Loop

    Homework Statement What is the strength of the magnetic field at the center of the loop in the figure? See attachment Homework Equations B = Mu_0*I/(2*R) The Attempt at a Solution I plug in the information to this equation and get .00038 Tesla which is incorrect. Does the...
  23. S

    Calculate Currents Through Ideal Batteries with Kirchhoff's Loop Rule

    "Use Kirchhoff’s rules to calculate the current through each ideal battery in the figure below. R1=1Ω, R2=2Ω, ε1=2V, ε2=ε3=4V. You should apply Kirchoff’s loop rule to the ε1-R1-R2-ε2-R1 loop, and the ε2-R2-R1-ε3-R1 loops respectively, each time starting from the negative end of the battery...
  24. B

    16 Bit Assembler Vertical Bar Loop

    Homework Statement Create a program that displays a vertical bar character ‘|’ moving left to right in 79 positions across the screen, then back right to left across the screen. Homework Equations (16 bit Assembler) The Attempt at a Solution .model small .stack 100h .data...
  25. N

    Resonance feedback loop on guitar

    Hey guys, I was messing around with my guitar (classical guitar) and my amp lately. I put the treble on lowest, bass highest, reverb highest, mid highest and mid frequency lowest. When I pluck a string when my guitar is close to the amp, the amplified sound from my amp causes that string to...
  26. B

    T/F Loop of a Wire Entering and exiting a field

    Homework Statement A square loop of wire with a small resistance is moved with constant speed from a field free region into a region of uniform B field (B is constant in time) and then back into a field free region to the left. The self inductance of the loop is negligible In case my image...
  27. D

    Parallel transport around a loop

    From the Wikipedia article on the Riemann curvature tensor: The last sentence assumes that ##\tau_{sX}^{-1}\tau_{tY}^{-1}\tau_{sX}\tau_{tY}## returns Z back to x0. It isn't obvious to me that this should be true. My guess is that this is true because X and Y commute, but I can't think of a...
  28. M

    Fortran How to Use FORTRAN Do Loops for Solving Equations - Step by Step Guide"

    Hey guys, I'm new to fortran and I'm having a slight problem. I put my code below as reference. I first set up a my known values. Then I used an equation to solve for v. After I solve for v I then computed c which involves v. What I'm now trying to do is to loop the value I got for c back...
  29. H

    Kirchhoff's Rule-Current in a Two Loop Circut

    Homework Statement Find the current in each branch of the circuit of the figure below . Specify the direction of each. ___|+5V_____/\/\/\/\____ |____________/\/\/\/\____| |___|+1V_____/\/\/\/\____| The top resistance is 22, middle is 56, and the bottom is 75. I'm predicting...
  30. N

    Closed Feedback Loop mechanical system examples

    Homework Statement Hello everybody I was hoping some of you could give me some some examples of some closed feedback loop mechanical systems. This is for my controls class where we have to design our own control system. I'm having trouble trying figure out some systems. I know one would...
  31. ShayanJ

    Conducting loop suspended in a magnetic field

    Consider a conducting loop with resistance R and area A suspended by a non-conducting wire in a magnetic field \vec{B}=B\hat{y} . The wire is a torsion spring with constant k.The equilibrium state of the loop is when it resides in the yz plane and its suspension is somehow that it can rotate...
  32. M

    Circuits (Nodal and loop anal. finding current through branch)

    I am trying to solve for isc. The correct answer is isc = 6mA but I got 0 mA. My equations must be correct... If they are not please someone explain why. Thank you.
  33. W

    MATLAB Vector concatenation without using a for loop (MATLAB)

    I have a variable number of vectors to concatenate in my Matlab model. Is there a way to do this without a for loop? The number will depend upon input parameters. Suggestions.
  34. K

    How to increment a MATLAB for loop by an arbitrary value?

    How to increment a MATLAB "for" loop by an arbitrary value? I am creating a Matlab program that calculates corresponding temperatures for Celsius, Kelvin, Fahrenheit, and Rankine scales. I want to write my code so that it can handle an arbitrary temperature increment (a user-inputted value)...
  35. J

    Time dependence of induced emf in a loop

    Homework Statement A uniform magnetic field B is perpendicular to the plane of a circular wire loop of radius R. The magnitude of the field varies with time according to B=B0exp(-t/τ) where B0 and τ are constants. The time dependence of the induced emf in the loop is a) exp(-t2/τ2) b)...
  36. .Scott

    Current Loop equivalent to Earth's Magnetic Field

    I'm trying to get a feel for the overall magnitude of the Earth's magnetic field. If I placed a superconducting belt around the Earth magnetic equator, how much current would that loop have to carry to approximate the Earth magnetic field? Currently, the field at the equator is about 31 microT...
  37. A

    Closed loop Servomechanism problem

    1. Homework Statement [/b] Hey Guys Firstly thanks for looking, I really appreciate any help or interest with my problem. The problem is a closed loop feedback system it's unlike any I have come across before. I have been given the definition which is as follows:- G(t)^-1 = 2.5...
  38. L

    Open Loop Transfer Function from Differential Equations

    Homework Statement Generate an open loop u(t) and simulate. Plot x(t) and y(t) \dot{x} = Vcos(θ) \dot{y} = Vsin(θ) \dot{θ} = u I am given initial values. All are 0 except for \dot{x}(0) = V. Homework Equations Laplace Transform Tables The Attempt at a Solution I think I...
  39. M

    Troubleshooting Phase Locked Loop Circuit with 3 ICs

    Hello, I am in need of big help here. I don't know what else should be done to get this correct. I have to build this PLL circuit and choose any 3 N (integer) of the N-divider. Then I have to observe the input signal Sig_in and the output signal VCO_out for each N. The result should be that the...
  40. D

    Direction of force on circular loop.

    Homework Statement Find direction of force on circular loop http://pokit.org/get/img/b886e52efb703d47d09fa6e781c74461.jpg What would hapend if direction of the current in a straight conductor were different ?Homework Equations ------The Attempt at a Solution...
  41. G

    C/C++ C++ pause and resume while(true) loop

    How to design a class, that executes an infinite loop, but may be paused, resumed and stopped by user input? I'll give you an example class Simulation { public: void start(){ m.init(); while(!m.isFinished()) m.update(); // computationally expensive calculation } void pause(); void...
  42. D

    A/m Hysteresis Loop: Wide vs Narrow Differences & Importance

    Wide/Narrow Hysteresis loops, what's the difference? When calculating the work done to magnetize a ferromagnetic material, calculating the hysteresis loop is the right way? I know the narrower loop(soft) needs less energy(work) to magnetize or demagnetize it is that true? That's why it's...
  43. Q

    Introducing Loop Quantum Gravity: Where to Start?

    If you search major book retailers on the internet, you can find lots of new and very good books on string theory, for both novice and more advanced students. However, for loop quantum gravity, you can't really find anything. Is there an introductory book that takes you from QFT to LQG ? Where...
  44. A

    Current passing through a loop

    Homework Statement A current of 5 A is passed through a single wire loop, producing a magnetic field of 3.4 x 10^-3 T at the center. What is the radius of the loop? Homework Equations B = μNi / 2r The Attempt at a Solution B = 3.4 x 10^-3 N = 1 i = 5 B = μNi / 2r 3.4 x...
  45. kira506

    Pleease explain uniformity of B in circular loop ?

    Why is the magnetic flux density uniform at the center of the circular loop ?
  46. Ascendant78

    Gravity and uniform circular motion involving a loop?

    Homework Statement A 0.27 kg toy car is held at rest against a 1796 N/m spring compressed a distance of 8cm. When released, the car travels a distance of 112cm along a flat surface before reaching a 0.30m high loop. The friction coefficient of the flat surface and the toy car is (0.4...
  47. G

    Circular current Loop I don't understand

    Suppose you want to find the magnetic field at a point p at the z axis from the picture attached. Attempt to understand this problem: The way the books solves it is that it says the angle theta between current element i ds and r is 90. Then he calculates the integeral which has two...
  48. B

    Finding the magnetic force in square loop wire.

    Homework Statement Suppose that the magnetic eld in some region has the form B = kzx(hat). (where k is a constant). Find the force on a square loop (side a), lying in the yz plane and centered at the origin, if it carries a current I, flowing counterclockwise, when you look down the x axis...
  49. H

    How do I create a matrix from a simple for loop?

    Homework Statement I am trying to create a code, in Matlab, that will describe the geometry of a PARSEC airfoil. The x coordinates for the upper and lower surfaces of the airfoil shape simply run from 0 to 1 (for a unit chord length). The z-coordinates (that describe the shape) are given by...
  50. S

    Loop of current rising in magnetic field

    I'm reading through my text (Griffiths Electrodynamics), and I'm working through an example in which he tries to dismantle a scenario where it is tempting to think that the magnetic field does work. The scenario is as follows, we have a square current carrying loop of wire of constant current...
Back
Top