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

    Mutual inductance of a long wire and a triangular loop?

    I originally posted this to the advanced homework -section, but maybe this isn't advanced enough to warrant being posted there :oops:. If a mod sees this, feel free to delete the original on the other forum. I'd do it myself, but I can't. 1. Homework Statement Calculate the mutual inductance for...
  2. I

    What is the Magnetic Force on the Loop in this Rigid Contour System?

    Homework Statement Rigid contour of an isosceles triangle and a long line cable lie in a plane and are located in vacuum . Determine the intensity of the magnetic force F acting on the loop. Current I = 100 A. free upload image Correct answer: F = 386 mN. I am getting 2 mN. Notice that I...
  3. B

    Gas and liquid flow rates in Gas-liquid flow loop

    Homework Statement I'm working on my research project at uni, running a gas-liquid flow loop for horizontal stratified flow exhibiting wave propagation. The equipment I have however is setup to investigate vertical flow primarily and the flow meters are located on the vertical sections. I need...
  4. M

    Help with magnetic induction and finding induced current

    Homework Statement I have attached a picture that details the problem. This is my practice test and I have no clue what I am doing wrong. Essentially a loop of wire is moving in constant velocity into a magnetic field. The magnetic field lines are pointing into the page. The problem is...
  5. R

    Finding currents using the junction and loop rules

    Homework Statement Homework Equations i1+i2-i3=0 50i1+75i3=1 100i2-75i3=1 The Attempt at a Solution matrix A=1 1 -1 0 100 -75[/B] 50 0 75 matrix B= 0 1 1 i1= -6ma i2= 23ma i3= 17ma My instructor gets i1= 6ma...
  6. A

    Open loop transfer function help

    Homework Statement [/B] I need to work out the open loop transfer function of the above. I've drawn it on word so it's not great; the + and - represent a summing junction. Homework Equations Everywhere I read, I find a different definition of open loop transfer function. I see G*H is an oft...
  7. J

    More Magnetic Fields -- 2 fields through a loop decreasing with time....

    This is a continuation of a previous thread in which I was informed my TA was mistaken on an aspect of magnetism. This thread is just to verify another problem within the homework is correct. Other threads will be posted to continue. 1. Homework Statement A) What is the magnetic flux...
  8. H

    Calculate the EMF induced in the square?

    Homework Statement A square of wire with side length 1.4 m rotates about an axis through one corner that is perpendicular to the plane of the square with an angular speed of 3 rev/s. There is a uniform magnetic field of 1.2 T perpendicular to the square. Calculate the EMF induced in the...
  9. A. Neumaier

    A Loop quantum gravity and diffeomorphism group

    How is loop quantum gravity related to the principle of relativity, in particular to the diffeomorphism invariance of general relativity?
  10. O

    MHB Trouble Printing Out Array Elements with a For Loop

    I am having problems with printing out each elements of the array using a for loop It's suppose to look like this: Enter non-negative numbers (ints) terminated by -99 1 2 3 4 5 6 -99 Original list (6 values): 1, 2, 3, 4, 5, 6. the code's output looks like: Enter non-negative numbers (ints)...
  11. Elvis 123456789

    Magnetic Field at the center of a square loop

    Homework Statement A square wire loop 12.0 cm on each side carries a clockwise current of 15.0 A Find the magnitude of the magnetic field at its center due to the four 1.30 −mm wire segments at the midpoint of each side. Homework Equations B = (μ0*I)/(4π)*(2a)/(x√(x^2+a^2)) The Attempt at a...
  12. Elvis 123456789

    Magnetic Field at center of a Square loop

    Homework Statement A square wire loop 12.0 cm on each side carries a clockwise current of 15.0 A Find the magnitude of the magnetic field at its center due to the four 1.30 −mm wire segments at the midpoint of each side. Homework Equations B = (μ0*I)/(4π)*(2a)/(x√(x^2+a^2)) The Attempt at a...
  13. B

    Rotational Energy, ball on a loop

    Homework Statement Imagine a ball with moment of inertia I_{cm} = \beta MR^2 encountering a circular loop of radius R_0 > R after rolling on a level surface at a speed of v_0. Assume that the ball does not slip. Attached a diagram. A) What is the minimum value of v_0 required for the ball...
  14. JesseJC

    3 loop circuit, 5 resistors, 2 batteries

    Homework Statement Full problem statement and diagram is attached. Homework Equations Kirchhoff's rules, ohm's law The Attempt at a Solution So I presume that what I'll be looking at here is the use of Kirchhoff's Rules and Ohm's Law. I do not know how to approach this as I have never come...
  15. B

    I Exploring the Popularity of Loop Quantum Gravity in Current Physics Research

    is Loop Quantum Gravity as popular as String Theory in current physics research?
  16. E

    Solve Homework 2: Electromotive Force in a Shrinking Loop

    Homework Statement A little stuck on the second question it basically boils down to not quite understanding the question. Was hoping someone here could push me in the right direction. The Question is two part, already completed the first half but wouldn't mind if someone looked over it while...
  17. C

    Computation of non scalar loop integrals

    Consider the following integral that comes out of a loop calculation along with some fermionic propagators (e.g virtual one loop correction to a ##p \gamma^* \rightarrow p'## process such as in DIS): $$ \int \frac{\text{d}^d l}{l^2 (l-p)^2 (p+q-l)^2} \text{Tr}(\not p \gamma^{\nu} (\not p + \not...
  18. F

    Electric current passing through closed loop

    Homework Statement (sorry for possible notation errors, that might arise during the translation) Why an electric current passing through a closed loop, can be defined only in stationary conditions? Homework Equations The Attempt at a Solution I think that the reason is that, if the...
  19. A

    Engineering Solve 2 Loop RC Circuit: Find Q(topen)

    1. Situation and Variables: A circuit is constructed with four resistors, one capacitor, one battery and a switch as shown. The values for the resistors are: R1 = R2 = 30 Ω, R3 = 66 Ω and R4 = 113 Ω. The capacitance is C = 64 μF and the battery voltage is V = 12 V. The positive terminal of the...
  20. N

    C/C++ C++: Using a for loop to print a countdown

    Write code that prints: userNum ... 2 1 Blastoff! Your code should contain a for loop. Print a newline after each number and after Blastoff!. Ex: userNum = 3 outputs: 3 2 1 Blastoff! #include <iostream> using namespace std; int main() { int userNum = 0; int i = 0; userNum = 3; i =...
  21. N

    MHB Using a while loop to print the counting numbers up to a set value

    Write a while loop that prints 1 to userNum, using the variable i. Follow each number (even the last one) by a space. Assume userNum is positive. Ex: userNum = 4 prints: 1 2 3 4 #include <iostream> using namespace std; int main() { int userNum = 0; int i = 0; userNum = 4; //...
  22. Tone L

    MATLAB Solving MATLAB Sum Loop Issue with 2,187 Data Points

    So i want to calculate an r value 5 different times then find the mean of the 5 calculated values. I have 2,187 data points. the first line of code generates 100 random points 1-2187. The code has a bug but my major issue is it calculates r then loops again calculates r, loops again calculates...
  23. K

    MHB Completing DoublePennies(): Solving the Infinite Loop

    Write code to complete DoublePennies()'s base case. Sample output for below program: Number of pennies after 10 days: 1024 The if statement is what I am trying to complete, however this places it in an infinite loop #include <stdio.h> // Returns number of pennies if pennies are doubled...
  24. N

    Kirchoff's Loop Rule Involving 2 Resistors and a Capacitor

    A 5μF capacitor is connected in parallel with a 2MΩ resistor and the combination is then connected in series with a 1MΩ resistor through a switch to a 12V battery. Find the time taken for the voltage across the capacitor to rise from zero initial value to 2V after the switch is closed.From what...
  25. endiewibowo

    I What is Returning Loop of Rogowski Coil?

    I read on a source from a paper from John D. Ramboz that explains: The incremental pitch-advancement of the coil's helical winding sums over its circumferential length to create an undesirable one-turn loop normal to the axis of the coil (the plane of this loop is parallel to the surface of the...
  26. Justice Hunter

    Exploring the Science of Feedback Loops in Social Media and Beyond

    So I'm trying to exploit the idea of audio feedback and applying it to different Sciences, The one I had in particular in mind is social media. But before I go hammering away at how to exploit it, I need a better understanding of how feedback actually works I believe that the way feedback in...
  27. UchihaClan13

    How can symmetry be applied in analyzing electric circuits?

    Okay guys So I was studying up some electric current and doing electric current problems I am clear with kirchhoffs rules And with series-parallel resistor combinations But I am not quite clear with the symmetric distribution of current Or symmetry in circuits, in particular Could you guys...
  28. komarxian

    Rollercoasters and Loops and Normal Forces

    Homework Statement <I will attach a diagram below> In terms of m, g and r. FInd the normal force at the top of the loop. Homework Equations ∑F = Fc = FN+Fg ∴ Fc=FN+Fg ∴FN = Fc - Fg ∴ N=mV2/r - mg The Attempt at a Solution Fc=mV2/r - mg and V2=ra and a=g ∴C=mrg/r ∴C = mg ∴mg-mg=N ∴ N=0 N. BUT...
  29. H

    Exploring Loop Variables: Understanding the Role of Photons in Closed Flux Loops

    Loop variables: A line of force or flux that is closed to form a loop. Can a Photon be a line of force or flux that closes to form a loop?
  30. DuckAmuck

    Why Do Electron, Muon, and Tau Masses Differ in Scale and Correction Effects?

    This is a 3 part question. 1. I've come to understand that the mass values in the mass terms (pole mass) of the standard model don't represent what we actually measure. That there are loop corrections. (I understand the concept: there's screening either adding or subtracting from the true...
  31. K

    SAT II Physics -- Induced current in loop (Faraday's law)

    Homework Statement A loop of wire and a bar magnet are moving relative to one another. Which motion in the diagrams shown below will NOT induce a current in the loop? Homework Equations Lenz's Law: A changing magnetic field can induce a current in a direction that produces its own...
  32. NihalRi

    Circular motion , the loop the loop

    Homework Statement The loop-the-loop machine has radius R of 18m (a) What is the minimum speed at which a cart must travel so that it will safety loop the loop (b) what will the speed at the top be in this case Homework Equations Centipetal force = m*v^2/r Kinetic and potential energies =...
  33. A

    What is the self inductance of a circular loop of wire?

    If current I passes through a circular loop of radius R,then what will be the self inductance of that loop? (calculating flux through the loop leads to calculating magnetic field at every point inside the loop which is an elliptic integral.)
  34. Safinaz

    Loop correction for quartic Higgs coupling

    Hi all, Has anyone an idea about the loop correction for quartic Higss coupling? In [arXiv:1507.03618v2 [hep-ph]], equ. (13) it's pointed out that the perturbativity constrains on the quartic couplings in the Higgs potential is ## \lambda^2 < 16 \pi^2 ## Which means that loop factor is ##...
  35. K

    Loop quantum cosmology vs string cosmology

    which of the two is better supported by observational evidence and is more researched?
  36. David Gin

    Determing flow of a closed loop parallel pumping system

    Hi all, How would one go about determining the flow(GPM) of a closed loop parallel piping system. I believe this has to do with the pressure intake and outlet of the pump as I have a pump in the mentioned system rated at 4350GPM@50Hz but it is pumping at 4500 GPM at 37Hz, Thank you all for...
  37. Safinaz

    Effective operator and allowed loop level interactions

    Hi all, Some processes can not happen at the tree level, but it happen via loops, like for Higgs decay to pair of glouns or pair of photons, (h -> gg), (h -> y y) . For instance, effectively h -> gg written as ##~ h~ G^a_{\mu\nu} G_a^{\mu\nu}~ ## which is Lorentz and gauge invariant .. Now if...
  38. kostoglotov

    Energy dissipated by a loop of muscle in an MRI machine

    edit: turned out to be a calculator typo...mods feel free to delete this thread if you wish, I won't complain. Homework Statement [/B] Having issues with part a) imgur link: http://i.imgur.com/4hzLyhb.jpg Homework Equations Resistivity of muscle (from table in text): \rho \approx 13...
  39. Gbox

    Why the current in a loop is the same

    If for example we have in a loop a DC and 2 resistors connected in series, the current in each resistor is different ##I=\frac{V}{R_i}## but we say that the current is ##I=\frac{V}{R_1+R_2}##? That means we are looking at the average current in a loop?
  40. K

    Does Loop quantum gravity have an effective UV fixed point?

    loop quantum gravity and loop quantum cosmology gravity becomes weaker then repulsive instead of stronger, towards the Planck regime, due to the onset of quantum effects. gravity near Planck energies and densities, LQG/LQC becomes repulsive. at the inflection point where LQG gravity strength...
  41. Q

    Induced Current in Square Loop

    Homework Statement A 21cm×21cm square loop has a resistance of 0.12 Ω . A magnetic field perpendicular to the loop is B=4t−2t^2, where B is in tesla and t is in seconds. (A) What is the current in the loop at t=0.0s? (B) What is the current in the loop at t=1.0s? Homework Equations for a...
  42. S

    Ampere's law with current loop

    Is it possible to find the magnetic field on the axis above a current loop using Ampere's law? I was thinking you could treat an infinitesimal piece of the loop as a straight wire and draw a circle around it with radius sqrt(a^2 + z^2), with a=radius of current loop and z=position of point of...
  43. L

    What is the current in the loop

    Homework Statement A piece of wire slides, without friction, along two similar wires. The resistance per unit length of all wires is 0.350 ohms/m, and a constant magnetic field, B= 1.90T, points up, perpendicular to the loop. The distance between the parallel, fixed wires is 10.0cm. At the...
  44. K

    Recent papers on self-dual loop quantum black holes

    self-dual loop quantum gravity results when the immirizi parameter y=i has been the subject of many recent research papers here is a partial listGravitational axial perturbations and quasinormal modes of loop quantum black holes M.B. Cruz, C.A.S. Silva, F.A. Brito (Submitted on 26 Nov 2015)...
  45. S

    Magnetic field of a circular loop

    Homework Statement A circular loop of radius R is on the xy plane and the center is at the origin, the current is flowing in a counter-clockwise manner. a) Let Q=(a,0,a) be a point such that a>>R. Find Br and Bθ at Q. b) Let Q=(ha,0,0) be a point on the x-axis such that h<1. Find the vector...
  46. K

    Towards self dual Loop Quantum Gravity Jibril Ben Achour

    interesting new paper on possible new research direction for LQG http://arxiv.org/abs/1511.07332 Towards self dual Loop Quantum Gravity Jibril Ben Achour (Submitted on 23 Nov 2015) In this PhD thesis, we introduced a new strategy to investigate the kinematical and physical predictions of self...
  47. H

    Vacuum diagrams vs. tree diagrams vs. loop diagrams

    Could someone please tell me the difference between tree diagrams and loop diagrams? If I'm thinking correctly tree diagrams are before contracting? Also how do vacuum diagrams fit into the picture? Thanks!
  48. J

    Can We Create an Endless Loop of Energy with Water?

    I have got a question. If we do electrolysis with waterand get : H2 + 02 , and then we make hydrogen explode and make a piston move , for example. Then it would be H2O again? So we could do this forever and get as much energy as we want? That would be super awesome but i am not sure.
  49. R

    Comp Sci C++ Why the loop going in infinite loop?

    Homework Statement I have to find GCD or HCF of two numbers. Homework EquationsThe Attempt at a Solution #include<iostream.h> #include<conio.h> void main() { clrscr(); int i,m,n,temp; cout<<"Enter two numbers\n"; cin>>m>>n; do { if(n>m) { temp=n; n=m...
  50. P

    Magnetic field from a square loop

    Homework Statement A wire is formed into the shape of a square of edge length L. Show that when the current in the loop is I, the magnetic field at point P a distance x from the center of the square along its axis is $$B=\frac{\mu_0 IL^2}{2\pi(x^2+L^2/4)\sqrt{x^2+L^2/2}}$$ Homework...
Back
Top