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

    Inclined throw in a vertical loop

    Homework Statement A small ball rotates in a vertical loop of radius R. it's velocity is the minimal required to stay in the loop. Now the loop is cut at an angle ##\alpha## and the ball shoots out of it. Express ##\alpha## so that the ball falls back into the loop and continues turning...
  2. L

    Op amp with zener in feedback loop

    Getting confused on understanding how opamp works with zener in Feedback loop. Referring to the ckt here (attached.) (replace diode with 5V zener) Using virtual short, when the input voltage is zero, opamp output is 5V? Basically the opamp sources current into the zener. When the input is -1V...
  3. K

    Plane in a vertical loop and gravity

    Homework Statement A plane makes a vertical loop like in the drawing. the speed is exactly what is needed that at the highest point the pilot won't feel any force nor from the seat and nor from the safety belts. 1) what is the weight of the pilot in comparison to the airplane? 2) what...
  4. A

    While loop - Variable not changing in C

    I am not sure if this is supposed to go in the homework forum or not since it is more of an off physics topic so sorry if it is incorrect. I have a programming assignment for class and I am having a lot of trouble with a while loop. For this part of the program I have to prompt the user to...
  5. H

    Mathematica Help with "Which[] in a For loop using Mathematica

    Hello, I am a novice in Mathematica, but insisting to learn it. I would appreciate help in solving the following problem: (*a=1;Which[a==1,x,a==2,b]*) list := List[1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 32, 10] For[i = 1, i < 4, i++, a = list[[i]]; Print[a]...
  6. F

    What Are the Best References for the Two-Loop Gluon Propagator?

    Does anybody know a good reference for the gluon propagator at two loop? I need it in Feynman gauge, but to have it in light-cone gauge as well is a plus. Preferably a paper, or a book that is common (i.e. easy to find in our university's library :-) ). Thanks!
  7. P

    Magnitude of electric field with square loop

    Homework Statement The square loop shown below is made up of four identical wires of length scripted l = 18 cm each charged with a linear density λ = 18 nC/m. Find the magnitude of the electric field at a distance z = scripted l/2 above the center of the loop. Homework Equations...
  8. ShayanJ

    Loop falling in a magnetic field

    There is a conducting circular loop with resistance R falling in the magnetic field \vec{B}=B_\rho(\rho,z)\hat\rho+B_z(\rho,z)\hat z and gravitational field \vec g=-g\hat z. How does z and the current in the loop change in time?(assume the loop remains horizontal!) The flux through the loop...
  9. A

    Finding the resistance, magnetic flux, and current of a loop section

    ...based on the angle. Homework Statement Figure 30-78 shows a wire that has been bent into a circular arc of radius r = 24.0 cm, centered at O. A straight wire OP can be rotated about O and makes sliding contact with the arc at P. Another straight wire OQ completes the conducting...
  10. W

    String Theory Vs Loop Quantum Gravity

    This is a question currently pondered by many Quantum physicists and theoretical physicists. I was just wondering how many of you prefer ST(string theory) as opposed to LQG(loop quantum gravity.) Please provide points and reasons regarding your answer. I will provide an opinion when a few...
  11. S

    Does a Glider Complete Its Loop Starting at 60 m/s with 30 m/s² Acceleration?

    Homework Statement I have to write a C# program for an assignment for school. Programming is not a problem, but physics is :P So I am kindly asking you guys for helping me out with this.. Sorry for my bad english, I'm not a native speaker. A glider pilot starts a back-loop with a plane...
  12. R

    Roller Coaster Loop: Solve for Height and Motion

    Homework Statement Hi, I am stuck on this thought experiment: A roller coaster of mass m starts on a inclined plane at a certain height, and then enters a circular loop, with radius r. At what height, h on the plane, must the trolley start in order to stop at the exact top of the loop...
  13. T

    Induced current and torque in a rectangular metal loop

    Homework Statement (a) The metallic rectangular loop of length b and width a (ABCD) is mounted in an assembly, which allows it to be rotated about an axis bisecting AD and BC. The plane of the loop makes an angle θ to the horizontal and a uniform magnetic field B is applied vertically...
  14. F

    Gauge Field Tensor from Wilson Loop

    It is possible to introduce the gauge field in a QFT purely on geometric arguments. For simplicity, consider QED, only starting with fermions, and seeing how the gauge field naturally emerges. The observation is that the derivative of the Dirac field doesn't have a well-defined transformation...
  15. T

    Chilled water loop pressure and velocity

    Where i work has a chilled water loop to every building for the ac system. A rooftop unit has not been performing as it should so we are investigating into the possible causes. Right now i am trying to come up with the different variables that accompany the givens. I know the pipe is 2.5", the...
  16. L

    Magnetic Flux through 1 loop due to current on the other

    The scenario is the following, I am given 2 loops with the same radius, r, a distance of d, and same current of I. In the left loop the current goes counter clockwise, in the right loop the current is clockwise. The two loops centers lie on the same axis which are perpendicular to the plane of...
  17. L

    Magnetic Flux through 1 loop due to current on the other

    The scenario is the following, I am given 2 loops with the same radius, r, a distance of d, and same current of I. In the left loop the current goes counter clockwise, in the right loop the current is clockwise. The two loops centers lie on the same axis which are perpendicular to the plane of...
  18. marcus

    Taking Bisognano-Wichmann into Loop

    http://arxiv.org/abs/1408.0121 Thermally correlated states in Loop Quantum Gravity Goffredo Chirco, Carlo Rovelli, Paola Ruggiero (Submitted on 1 Aug 2014) We study a class of loop-quantum-gravity states characterized by (ultra-local) thermal correlations that reproduce some features of the...
  19. I

    Find EMF - Loop inside a loop generating a magnetic field

    Homework Statement A loop of wire with an area 1cm^2 is centered within a larger loop of area 1m^2. Apower supply is generating current through the larger loop described by the function: I(t) = 40A * cos(2t/s * 2pi/5) Calculate EMF at time t = 3sHomework Equations Magnetic flux =...
  20. ShayanJ

    Vector potential of a current carrying circular loop

    Consider a circular loop of radius R that carrys a uniform current I. We know(by Biot-Savart law) that the magnetic field it produces on its axis is given by \vec{B}=\frac{\mu_0 I R^2 \hat z }{2(z^2+R^2)^\frac 3 2} . But let's calculate its vector potential: \vec{A}=\frac{\mu_0}{4\pi} \int...
  21. Hepth

    Feynman Diagram setup for 4-fermion interaction loop

    If one has a 4-fermion vertex, like in Fermi theory : ##G_f (f_1 \Gamma f_2)(l_1 \Gamma l_2)## And you are calculating a one-loop diagram where you have the diagram of : f1-> f2,l1,l2 -> f1 (used for dispersive/unitarity approach) Where in the end you'll use Cutkosky rules to calculate...
  22. Radarithm

    Electric field above a circular loop

    Homework Statement Find the electric field a distance z above the center of a circular loop of radius r that carries a uniform line charge λ. Homework Equations $$E=E_r\hat{r}+E_z\hat{z}$$ $$E_r=\frac{\lambda}{4\pi\epsilon_0}\int_0^r\frac{1}{\mathcal{R}^2}\sin{\theta}\,dr$$...
  23. M

    Calculating Velocity for a Loop the Loop

    Hi, i need to calculate the minimal velocity at point A to reach point B Not asked to complete full loop, There is no friction. I guess (mv^2)/2 = mg*2r >>> v = sqrt(4gr), my friend say v = sqrt(5gr) Thanks.
  24. P

    How can I import a hysteresis material's loop into Ansoft Maxwell?

    hi my dear friends i face with a problem in ansoft maxwell; i want to import a hysteresis material's loop into maxwell's material s libraray but i cant!:( is there anyone who can help me? with the best wishes:) pedro
  25. gfd43tg

    While end loop to find pattern in array

    Homework Statement Write code using a while loop that will assign to the variable numOccursSep the number of times a certain pattern of 0's and 1's occurs separately in V. The variable pattern gives the certain pattern to look for. For this problem overlap is not allowed, i.e. if pattern =...
  26. T

    What Happens to Inductance with Changes in Current and Loop Configuration?

    Hello, I'm new to this forum. I hope I am submitting this to the right thread. Just started physics and I am looking to get a little assistance Homework Statement A single loop carries 100mA and has an inductance of 100μH Homework Equations For air cored L = μ0 * (N^2*A/length) L = Nø/i...
  27. W

    Finding the velocity at the top of a loop

    Hey Guys. I've been spending the last 1½ week trying to figure this out on my own, but I just can't find the answer. A car (toy car) weights at about 0,062 Kg, and enters the loop at the speed of 0,60 m/s. The radius of the loop is 0,2011 m. Find the speed at the top of the loop (Not...
  28. fluidistic

    C/C++ C++. Modifying a particular program, loop

    Hello! As a new past time I wanted to learn some coding. A friend of mine wrote a program and explained it from A to Z to me, it took like 2 hours. I wanted to play a bit with the program by modifying it. Here's the code: #include <stdlib.h> #include <iostream> #include <time.h> using...
  29. K

    Control Bandwidth & Closed Loop Bandwidth Meaning?

    Can anyone tell me if Control bandwidth and closed loop bandwidth means the same thing? If not what does control bandwidth mean? Please & Thank you!
  30. baby_1

    Find Induced voltage in a loop

    Hello here is a problem that we want to find induced voltage in two different questions. 1-here is part (a) solution: question 1:why we get integral in all space of conducting rail instead of bar space?(Area of bar)for example if we enlarge the space and set bar fix again induced voltage...
  31. B

    Induced voltage in rectangular loop

    Homework Statement There's a magnetic field B in +\hat{z}. A rectangular loop is lying in the xy-plane. Three sides are static, the 4th one is moving with velocity v along the direction of +\hat{y}, making the rectangular larger and larger. The length of this moving side of the rectangle is L...
  32. D

    Constant angular speed loop of wire

    Homework Statement You have a loop of wire (dimensions c and d) which is oriented vertically on the y-axis (the y-axis splits the rectangle in two equal pieces), and rotates about the y-axis at constant angular ##\omega##. The magnetic field is in the +i direction. What would be the torqque...
  33. R

    Pump head requirement: Closed vs Open loop

    If a pump pumps water to a heat exchanger at a certain height, say, 20 m is the head required indeed lower for a closed loop system than an open loop system? The link below says so, but I wanted to verify. Assume pipe friction losses are the same in both cases. Can one really take credit for...
  34. J

    Converting a recursion to a loop

    public static int function(int n, int a, int b){ if (n>0){ if(b==0) return a; else return function(n-1,a,function(n,a,b-1)); } return b; } I have a recursive function of this form, how do I convert it to a loop?
  35. D

    Rectangular loop near wire emf

    Homework Statement http://web.mit.edu/viz/EM/visualizations/coursenotes/modules/guide10.pdf pg: 10-17 Homework Equations The Attempt at a Solution I do not understand conceptually, why we chose the rectangular surface to take the flux over. Can anyone explain this...
  36. J

    Can't Skip missing files in loop

    Hi all, Thanks in advance! I'm almost new in Fortran, and I'm having some troubles with a Fortran program. I've some input data files named with numerical values like "Input_A=0.00_B=0.00" "Input_A=0.10_B=0.01" "Input_A=0.20_B=0.02" "Input_A=0.30_B=0.03" "Input_A=0.40_B=0.04" ... ...
  37. Avatrin

    Kirchoff's loop rule with multiple voltage sources

    Hi Let's look at this: The issue I am having is that while I know that this is accurate: I just cannot wrap my head around why. I1 is a result of both voltage sources. So, while the equations clearly tell me that the voltage drop across the resistor R1 is I1R1, I cannot wrap my...
  38. C

    Particles moving freely on a vertical/horizontal loop

    Homework Statement 1) A mouse of mass ##m## runs around the inner circumference of a vertical circle which is free to rotate about its centre. The mouse starts at the bottom of a stationary wheel. Let ##\phi## be the angle that the radius vector of the mouse makes with the downward vertical at...
  39. lonewolf219

    Finding the magnetic field at center of a square loop

    My textbook says that at the center of a square conducting wire of length ω, the magnetic field is: B=\sqrt{2}μ_{0}I/(\piR) I am not sure how to calculate this...? Because the Biot Savart law has a closed loop integral, we do not use piecewise addition of line integrals to find the...
  40. G

    Conducting rod is free to move over a loop under influence of B field?

    Homework Statement The conducting rod ab shown in the figure (Figure 1) makes contact with metal rails ca and db. The apparatus is in a uniform magnetic field 0.800 T, perpendicular to the plane of the figure. If the resistance of the circuit abdc is 1.50 Ω (assumed to be constant), find...
  41. N

    Plotting results from for loop

    Plotting results from "for" loop Hello, I have a problem which it seems I couldn't solve. I have "for" loop which gives results of some calculations as, say, vectors with two coordinates. What I want is to plot the result as a point in the xy plane. This loop goes on and on with the...
  42. M

    Fortran Fortran DO loop sequence confusion

    I am trying to convert a FORTRAN version of a Canonical Correlates program listed in Multivariate Morphology - Blackith and Reyment. I've programed in FORTRAN decades ago and now I have to understand the language to rewrite the program into PERL. a) DO 260 I = 1 , M b) SX( I ) =...
  43. S

    Finding The Induced Current in This Loop

    Homework Statement Hey guys, I have a physics II test tomorrow on Electricity and Magnetism, and I cannot seem to figure out this question. The rectangular loop in the figure has 2.2×10−2Ω resistance. What is the induced current in the loop at this instant? Picture: Homework...
  44. L

    Is the term loop loosely defined in Faraday's law?

    Is the term "loop" loosely defined in Faraday's law? A voltage will be induced in a loop of wire when the magnetic field flux through the loop changes If you're reading this, you probably know what happens when you hook up the leads from an oscilloscope to a microphone. Nothing, lol. There...
  45. F

    How high to complete the loop?

    Problem: A little roller coaster (see attached image) is at a certain height h and starts moving downwards, Neglecting the friction and drag. From what height does the coaster have to start in order to complete a full loop with radius a without coming of the track? h should be expressed in a...
  46. W

    Java Java While Loop and If statement

    I am reading an input file that has blank lines. x reads character by character. x is equal to a new line so it goes into the while loop but skips the if x == '\n'. It's suppose to go inside the if statement but it doesn't. I tried debugging the code and printed out to double check x is holding...
  47. U

    Conducting loop placed in magnetic field

    Homework Statement A uniformly conducting wire is bent to form a ring of mass m and radius r, and the ring is placed on a rough horizontal surface with its plane horizontal. There exists a uniform and constant horizontal magnetic field of induction B. Now a charge q is passed through the ring...
  48. D

    MATLAB Solving Matlab for Loop Issue with di Index Value

    t = (0:0.0001:10); for ki = [0.625, 1.125] kp = 1.25; H = tf([0, 0, 2*kp, 2*ki], [1, 3, 2 + 2*kp, 2*ki]); step(H, t) for i = [1, 2] di = stepinfo(H) end hold on end legend('kp = 0.625', 'kp = 1.125'); I want the di loop to return d1 = all the data and d2 = all...
  49. T

    If the loop is rotated in the opposite direction by the same amount, w

    If the loop is rotated in the opposite direction by the same amount, which change in magnetic flux is true? (Select all that apply.) a)It has the same magnitude. b)It has a smaller magnitude. c)It has the same sign. d)It has a larger magnitude. e)It has the opposite sign.
Back
Top