Loop Definition and 1000 Threads

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. 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...
  2. 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...
  3. P

    How the Classic Loop the loop works

    Through some of the conservation of energy problems we've been working recently with the loop the loop (ball rolls down ramp and around a circular track.) there is one concept that is irritating me. This is not a homework problem but a mash up of the driving concepts from a few different...
  4. xSpartanCx

    Faraday's law with loop of wire and resistor

    A coil 3.65 cm radius, containing 560 turns, is placed in a uniform magnetic field that varies with time according to B=( 1.20×10^−2 T/s)t+( 3.05×10^−5 T/s4)t^4. The coil is connected to a 600-Ω resistor, and its plane is perpendicular to the magnetic field. You can ignore the resistance of the...
  5. I

    Loop-de-Loop with function of angle

    Homework Statement Task: [/B] On a friction free loop de loop, a object (m=600kg with passengers) moves with a velocity of vu = 120km/h at the lowest point of the loop. The loop has a radius of r=15m. The position of the object is given with the angle α. Derive the formula for the velocity...
  6. V

    Direction of current in a magnetic field when loop is square

    Homework Statement A flexible wire loop has a radius of r = 0.178 m and it is inside a uniform magnetic field of B = 0.332 T. The loop is grasped at points P and Q and stretched until its area is zero. It takes 0.146 s to close the loop. Homework Equations EMF = ∆Phi/∆t Phi = magnetic flux...
  7. G

    Electromagnetism help: Find magnetic flux through a loop

    Homework Statement Very large conductor with DC current is in vacuum. Find magnetic flux through a loop. Given parameters: I,a,\alpha Homework Equations \Phi=\int_S B\mathrm dS - basic equation for magnetic flux B=\frac{\mu_0I}{2\pi x} - electromagnetic induction created by very long...
  8. JasonHathaway

    Electromagnetics: Moving loop in a static magnetic field

    Homework Statement A conducting square loop (L × L) moving with velocity vo ay m/s where the magnetic flux density is B=Bo ax Wb/m2 in 0 < y < 2L, and is equal to zero when 0 > y and y > L. Determine the current in the loop and plot its magnitude as a function in the loop's position in the...
  9. Tone L

    MATLAB Solving MATLAB Loop with X & Latitudes

    I have a list of latitudes: lats = 41.0100000000000 43.7800000000000 44.4200000000000 41.2500000000000 42.8000000000000 42.7500000000000 42.4900000000000 42.4900000000000 42.7800000000000...
  10. uselesslemma

    Force on a Circular Loop Due to an Infinite Wire

    Homework Statement A long straight wire carrying a constant current I1 and a circular wire loop carrying a constant current I2 lie in a plane. The radius of the loop is R, and its center is located at distance D from the straight wire. What is the magnetic force exerted on the loop by the...
  11. E

    Current flowing through a loop due to an infinite wire

    Homework Statement An infinitely long wire carrying a 1 A current in the positive x direction is placed along the x-axis in the vicinity of a 5-turn circular loop located in the x-y plane as shown in the figure. If the magnetic field at the center of the loop is 0, what is the direction and...
  12. gfd43tg

    What are the Closed Loop Transfer Function Parameters for a PI Controller?

    Homework Statement Homework EquationsThe Attempt at a Solution I don't think you need to see the problem to figure this one out, if needed I will post it (takes up a lot of space in the thread). I know for a PI controller, the controller transfer function is given $$ g_{c} = k_{c} \frac...
  13. E

    Magnetism Wire Loop: Solve Problem in 1.5 Hours

    Okay guys I have an hour and thirty minutes before my exam; I know how to do the top problem; just use the formula B = mew x current/(2 x pi x r) then add the magnetic fields and use the right-hand rule to get direction, but I'm stuck on the bottom one.
  14. teetar

    Problem with conducting loop and magnetic field

    Homework Statement A rectangular conducting loop of wire is approximately half-way into a magnetic field B (out of the page) and is free to move. Suppose the magnetic field B begins to increase rapidly in strength. What happens to the loop? Homework Equations Not sure which ones are relevant...
  15. TheMathNoob

    Infinite loop iterating over a linked list

    Mod note: Added code tags 1. Homework Statement in my main I am getting infinite loop iterating over a link list Homework EquationsThe Attempt at a Solution /* * graph.c * * Created on: Oct 8, 2015 * Author: danif */ #include <stdio.h> #include "IntList.h" int main(void) { typedef...
  16. K

    Where can I study (research) Loop Quantum Gravity?

    Thank you for opening this Thread I am kind of new here and this is my first time to post so I apologize if I did something wrong So my question is where can I study/ research Loop Quantum Gravity I have checked fair amount of grad school websites and compared to Super String, I have not yet...
  17. R

    Terminal velocity of loop falling through magnetic field

    Homework Statement https://physicsforums-bernhardtmediall.netdna-ssl.com/data/attachments/72/72755-bc8e4b32405460abcfa2d8e4880f7037.jpg I'm trying to figure out the terminal velocity of the loop as it falls through the magnetic field (figure 7.20). 3. The Attempt at a Solution The...
  18. O

    Task: Function for the acceleration throughout a loop?

    So, this seemed really fun to me until I got stuck. THE TASK is about an object with mass m, moving in a basic (2D) coordinate system. It is attached to origo (0, 0) by a "rope" with constant length r=5. In position P0(-5, 0) it has the velocity v0=[0, -10]. Hence, the object moves around origo...
  19. Nouo

    Calculating minimum velocity around a loop

    So I had this question for physics about something going around a loop. The question asked what the minimum velocity to counteract gravity is if something is going around a loop. hint: One force will be zero. I'm not sure how to figure this out, can someone help?
  20. K

    Understanding KVL Loop in BJT Biasing and Calculating Ve

    Please help how Ve is calculated what i think is that it should be: -Ve=-Vee+IeRe; How Ve is taken positive please someone draw equivalent circuit for same
  21. P

    What is the new Hamiltonian constraint operator for loop quantum gravity?

    A critique of LQG here: "The next step in the construction of LQG is to decide what the dynamics are. Technically, this is done either (A) by choosing a "Hamiltonian constraint" in parallel with the Hamiltonian formulation of GR, or (B) in the spin-foam formalism, by postulating some sort of...
  22. S

    Ground Loop Problem: Solving DC Offset in Video

    Hello, i have a really annoiyng problem , i have a robot which is equipped with a video camera(PAL) so nothing too fancy, the information is transmitted through a coaxial cable about 200 m of cables,the attenuation of high frequency is not to big to cause any problems,also the robot has some...
  23. Q

    Is Loop Quantum Gravity a Machian theory?

    Hi All! I have heard that loop quantum gravity is a "background independent" theory, in that there is no preferred coordinate system. Is LQG also a Machian theory?
  24. C

    MHB Implementing Loops to Modify Code - Loop Modification

    a) The following code implements a for loop, a do while loop, and a while loop. There are stubs for four additional loops. You are to add the code necessary to implement the missing loops as indicated by the comments. When adding code for a for loop, you must fill in all three parts in the for...
  25. E

    Magnetic hysteresis loop area meaning

    Let's consider the Magnetic hysteresis loop of a certain material: https://www.nde-ed.org/EducationResources/CommunityCollege/MagParticle/Physics/HysteresisLoop.htm is an example. In many sites and books it is written that its area is proportional to the energy wasted as heat, so A = kE_d. In...
  26. D

    Fortran Why Does This Fortran Code Result in an Infinite Loop?

    I've inherited the code below. It's giving an infinite loop but I can't find what's causing it. This is code originally on OpenVMS written now for AIX. Can you help? SUBROUTINE MREAD3(N_VESSEL,N_TRIP,N_ICNAF,N_SPECIES,N_DELSTR, + N_SETDEL,N_SELSTR,VESSELS_TO_BE_SELECTED, +...
  27. O

    How to Track Unique Objects Passing Through a Gate at High Speed?

    hello, i need to uniqly identify up to 10 (or maybe more) different objects passing a 4x4m big gate with 200km/h speed. right now we use an IR transmitter and reciever, but the problem is, one can hardly say for sure if the transmitter 100% passed though the gate, or just next to the receiver...
  28. R

    A semicircular loop of radius a carries positive charge Q....

    Homework Statement A semicircular loop of radius a carries positive charge Q distributed uniformly... Find the electric field at the loop's center (point P in the figure). Hint: Divide the loop into charge elements dq as shown in the figure, and write dq in terms of the angle dθ, then...
  29. Jairo Rodriguez

    Dropping a mass on a slope, entering a loop and stopping.

    Hello, today our teacher told us that on tomorrow's test there is going to be a problem where you drop a mass on a slope which connects into a loop. The point of the problem is to calculate exactly how tall the slope must be for the mass to complete exactly one course through the loop...
  30. A

    Induced Voltage in an unclosed loop

    I read the following problem on a textbook: A airplane flies at a constant speed of 680m/s perpendiculary to Earth's magnetic field (of 5x10^-5 T). The wingspan of the airplane is 9.8m. What is the induced voltage? The answer the book gives is: E = BLv = 0.4066V But I've been wondering if this...
  31. Blank_Stare

    Moving small quanities of water in a pressurized loop

    First time here. I browsed around a bit, but did not see a topic quite like what I am about to write, so I started a new topic. If I missed an existing topic, please point me to it, and I will thank you for doing so. Please select a prefix? I seem to remember some of this from High School...
  32. Q

    Current density in an elliptical loop

    Suppose we have an elliptical loop of wire in the x-y plane with constant cross-section. And let's also assume that the cross-section is very small, so we have a thin wire. $$\vec{r}=\begin{bmatrix} x \\ y \end{bmatrix}=\begin{bmatrix} a\cos \theta \\ b \sin \theta \end{bmatrix}$$ A tangent...
  33. D

    Magnetic field at the centre of a circular current loop

    Homework Statement How to calculate the magnetic field at the centre of a circular current (I) loop of radius r using Ampere law Homework Equations B = μ0I/2r The Attempt at a Solution I take circulation along the circular closed path of radius r passing through the center of the loop and...
  34. Mr. Rho

    Outside the origin circular loop current density

    Hi, I'm trying to write the current density for such circular loop in spherical coordinates. For a circular loop of radius a that lies in the XY plane at the origin, the current density it's simply: \mathbf{J}= \frac{I}{2\pi\sin\theta}\delta(\theta-\frac{\pi}{2})\frac{\delta(r-a)}{a}\hat{\phi}...
  35. Y

    Magnetic field due to a loop within the area of the loop

    Homework Statement This is a question me and my friend were wondering about. How can one calculate the magnetic field due to a current carrying loop at a point in the area enclosed by the loop. For example, at point P as shown in the attached figure. Homework Equations $$B =...
  36. Daniel Reyes

    Where Can I Find Software for Calculating Tensor Loop Integrals?

    Hi there! I was wondering if anybody knows what package or software CERN of other particle accelerators use to calculate their theoretical predictions. I need specifically tensor loop integrals of up to rank four and of three and four vertices. Thanks!
  37. G

    Getting an infinite loop in Nelder-Mead code, help please

    I've been making a go at writing out algorithms myself in MATLAB rather than using pre-existing code. I've just attempted to write the Nelder-Mead optimization method and I have hit a stumbling block where the code is now looping infinitely. It seems to have something to do with sorting the...
  38. K

    Is there a good candidate Hamiltonian for loop QG?

    is there a generally accepted candidate Hamiltonian for LQG? i've seen marcus post these papers recently http://arxiv.org/abs/1507.00986 New Hamiltonian constraint operator for loop quantum gravity Jinsong Yang, Yongge Ma (Submitted on 3 Jul 2015) A new symmetric Hamiltonian constraint...
  39. A

    Find the magnetic force on the square loop

    Homework Statement A square loop PQRS carrying a current of 6A is placed near a long wire carrying 10A as shown in the figure. Find the magnetic force on the square loop. Homework Equations F = B * i * l ...... (1) B = (µ0 * i)/2 π r The Attempt at a Solution I tried finding out the...
  40. Salvador

    Coil loop with a magnet through it produces AC or DC?

    Here is my misunderstanding , for the example let's ignore resistance losses , say i have a infinite length of coil , and an infinite strip of magnets passing through that coil, each magnet separated by some distance from the next one , the strip of magnets move through the middle of the coil ...
  41. C

    Determining Minimum Height to Complete a Loop

    This question was posted on Khan Academy. I attempted it after watching all of their great Work and Energy videos, but the way they arrived at the answer was way above my skill level even after reviewing the videos a number of times. Here is the question: What is the minimum height h of a slope...
  42. Georges Simenon

    Linear simplicity constraint in Loop Quantum Gravity

    Homework Statement Hi, I am studying covariant LQG from the recent book by Rovelli & Vidotto, and i am struggling with the linear simplicity constraint. My problems are not with its proof, that i understand, but rather with the physical interpretation in terms of boost generators. I will try to...
  43. K

    Fortran Fortran : generating different output files in a loop

    implicit none character*4 head1,head2,ext character*10 fn1,fn2 integer i,kev head1='jack' head2='jill' ext='.dat' do i=1, 50000 kev=int((i-1)/50)+1000 if(mod(i,50).eq.0) then write(fn1,'(a,i4,a)') head1,kev,ext write(3,*) fn1 write(fn2,'(a,i4,a)') head2,kev,ext...
  44. G

    Closed loop problem for lighting in thunderstorm?

    Hello. As far as I know, every circuit capable to flow current must be closed. In other word, open circuit can not flow the current, obviously. Right now, I would like to know this is also true for lighting in bad weather. When bottom of the dark and heavy cloud get more and more electron by...
  45. A

    A circular loop over a magnetic field directed outwards

    Homework Statement There is a counterclockwise current I in a circular loop of wire situated in an external magnetic field directed out of the page as shown. The effect of the forces that act on this current is to make the loop Select one: a. expand in size X b. contract in size c...
  46. Hercuflea

    Python [Python] Why does this loop execute 4 times?

    I've written a code which reads in an input file and extracts a number which represents a grid size, from lines in the file which can contain arbitrary characters. The extraction of the data seems to be working, but for some reason the loop executes 4 times and then moves on to the next...
  47. K

    Conformal gravity vs loop quantum gravity

    if conformal gravity is a successful research program, what would its implications be for loop quantum gravity? can conformal gravity be loop quantized? can loop quantum gravity be made to respect conformal invariance? or are the two mutually exclusive?
  48. M

    Checking Control Loop Calibration

    Homework Statement Homework EquationsThe Attempt at a Solution Process actual at 300 Transmitter range 100 - 420 Output 4 - 20mA Output Actual 15.43mA Conditional output 3.85 PV and SP at 300 Valve position at 30% Anyone can help if I am on a right track? I am not sure how to start...
  49. A

    Wilson Loop and spontaneous symmetry breaking.

    I would like to ask about the case of: ##SU(2)\otimes U(1) \rightarrow U(1)\otimes U(1),## spontaneous symmetry breaking. It is given that the Wilson Loop: ##W \equiv exp[ig \oint dy H T^1]= diag(−1,−1,1).## Where ##y## is the ##S^1/Z^2## fifth/extra dimension, ##H = \frac{1}{g R}## and...
  50. S

    Electromagnetics: Reducing inductance of a wire loop

    Given a flexible wire loop of a certain perimeter and planar shape, what are some good ideas to minimise the loop's inductance? For example, would it work if i surrounded the wire loop with a superconducting loop in the same plane?
Back
Top