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.
I need some help in optimizing a code with a prompt yes/no...My problem is that if I mistype within the loop for r some character (let's say I'm missing the number 8 on the keyboard for u) the program gets into an infinite loop.
Do you know some way that I could solve this problem? Like printing...
Homework Statement
The wire loop ##ABCD## is in a magnetic field of the long thin rod magnet with a magnetic moment per unit volume of ##\mathfrak{M}_0## and a cross section ##S##. The north pole of this magnet is in the center of the loop, and the magnet is perpendicular to the plane of the...
Homework Statement
Problem 6.2 of Griffith's "Introduction to Electrodynamics": Starting from the Lorentz force law ##\vec F=\int I (d\vec l \times \vec B)##, show that the torque on any steady current distribution (not just a square loop) in a uniform field ##\vec B## is ##\vec m\times \vec...
Homework Statement
[/B]
3. A square loop of area a 2 is formed from a single turn of thin wire of resistance R. The loop is aligned with two sides parallel to an infinite straight thin cable, with its closest side a distance r away, and is given a velocity v in a direction perpendicular to the...
Does anyone know a simple explanation for the following statement:
Gauge invariance ⇒ $Πμνϒϒ(0) = ΠμνϒZ(0) = 0$
Where ΠVV' is the V to V' one loop correction, ϒ is the photon field and Z is the Z-boson field. The argument of Π is the incoming momentum q2 = 0
It is my general understanding that according to KCL, current requires a closed loop to flow in DC. However, this is apparently not true in AC; current doesn't needa closed loop to flow.
I have drawn a circuit below which causes confusion:
C1 is a charge capacitor, R1 is a resistor, I1 an...
Homework Statement
Homework Equations
I have some equations relating B to I but I don't really know if they are useful
The Attempt at a Solution
I actually don't even know where to begin on this, my notes are confusing and vague :(
as u know torque is given by NI(A X B) where N and I are number of loop turns and current magnitude respectively, A is area in vector and B is magnetic field in vector. regarding the direction of area : what normal to take as a direction, is at that which makes acute angle with magnetic field...
Homework Statement
An elastic circular loop in the plane of the paper lies in a 0.81 T magnetic field pointing into the paper. If the loop's diameter changes from 19 cm to 6.8 cm in 0.45 s,
a. what is the magnitude of the average induced emf?
b. If the loop's resistance is 2.3 Ω, what is...
I am planning to build a rogowski coil but not the conventional one, which is a circular loop.
Below is the example of a rogowski coil so you have the big picture of my question.
In the picture, the current conducting wire (with current Ip) is encircled by a big circular loop rogowski coil...
Homework Statement
A rectangular loop of wire is placed next to a straight wire, as shown above. There is a current I in both the straight wire and the loop. The dimensions shown in the figure are a, b = 2.2a, and c = 8a. What is the magnitude of the force on the loop? Express your answer in...
I'm trying to derive a formula for the magnetic torque on a semicircular loop.
what I've done so far is this
The magnetic force on the non-curved loop is
$\vec{F}_{x}=\int Idx\hat{i}\times B_{\circ}\hat{i}=0N$
for the curved loop
$\vec{F}_{c}=\int_{0}^{\pi} Ird\phi\hat{\phi}\times...
Dear Friends! I need to find roots of polynomials with variable coefficients, The command I used is
w=0:50
A=w^2
B=w^3+2
C=w+2*w^2
D=w
E=w./2
ss=[A B C D E]
xi=roots(ss)
by this I find all the roots of equation,
I want to find velocities by setting
v1=w/xi(1)
v2=w/xi(2)
v3=w/xi(3)
v4=w/xi(4)...
Homework Statement
[/B]
A circular loop of wire, of radius r, carries current I. It is placed in a magnetic field B whose straight lines seem to diverge from a point a distance d below the ring on its axis. (That is, the field makes an angle θ with the loop at all points, where tan(θ) = r/d.)...
I have been reading about M-Theory and LQG, and from what I read they are actually very similar.
It seems that just a a string-world sheet is the same as a sum of an infinite number of Feynman diagrams, a membrane would be the sum of an infinite number of graphs or networks. Or as Susskind...
Homework Statement
The area bounded by the loop of the curve ## 4y^2 = x^2(4-x^2) ## is in sq. units
7/3
8/3
11/3
16/3
Homework Equations
NA
The Attempt at a Solution
By putting x = 0 and x = 2 I am getting y = 0.
Getting complex y values after x exceeds 2.
I am not getting where the loop...
Homework Statement
This is a past exam question which I just for the life of me can't figure out.
http://tinypic.com/r/2eq6ryo/8Homework Equations
My guess is that the energy of the magnetisation is equal to the gravitational energy
Relevant Equations:
Ems = Mass * g * δ
Where
Mass = ρ *...
Hi friends..I'm struggling with an interesting puzzle...Suppose there is a circular conducting loop of radius 1/π cm, one half of which is made of a material with resistance 1Ω and the other half from a material with resistance 5Ω. If somehow, one managed to set up a changing magnetic field...
Here is a portion of the explanation my book gives
"Kirchoff's second rule follows the law of conservation of energy. Let's imagine moving a charge around a closed loop of a circuit. When the charge returns to the starting point, the charge-circuit system must have the same total energy as it...
Usually in textbooks Ampere's law is just illustrated using 2D loops which forms a plane. Can the law be applied to 3D loops which cannot form a plane surface within the loop?
In a 3D loop which surface should we count when we count the current? In 2D case it is easy because there can only be a...
for example, is loop quantum gravity/SF in 4 dimensions dual to a CFT in 3 dimensions?
does a serious proposal of QG have to respect the holographic principle?
Homework Statement
Problem and solution attached
Homework Equations
B = [4uI/(4pi)]sin(theta1-theta2]
The Attempt at a Solution
I understand fully how to do it except determining the value of theta1 and theta2. The solution says theta1 is 45(deg) and theta2 is -45(deg). How did they get those...
Homework Statement
Sorry to bother you guys,
I've heard that Ampere's Law is either ineffective for calculating the B field due to a circular loop or needs some modification (I wasn't sure which).
I'm trying to figure out why this doesn't work so I can get a better understanding of Ampere's...
There are plenty of examples where someone derives the magnetic force from a current carrying wire on a moving charged particle by looking at the frame of the particle and finding that the current has Lorentz contracted in such a way as to produce an electric field in an otherwise neutral wire...
Homework Statement
Homework Equations
Faraday's and Lenz' law.
emf = -d(ф)/dt
The Attempt at a Solution
The current is increasing upwards during that time interval.
Thus, by Right-Hand-Rule, the magnetic field goes into the page at the loop.
Lenz' law says that the loop's induced emf...
I have been thinking about coils of wire carrying alternatingcurrent. From what I understand, a back emf is induced in the coil because there is a changing magnetic field around each individual loop of wire, and therefore there is a changing flux through each loop because the changing field...
In common test books the "proof" is usually use an example of a simple one-loop system with battery and resistor. In such a case, the current actually goes round the loop and the same current flows throughout the loop.
However in actual case, there may be different currents in different...
Homework Statement
A conducting square loop placed in the xy plane (oriented with its horizontal and vertical sides parallel to the x and y axes) moves to the right across the y-axis at a constant speed of 2.0 m/s, a 0.63-V emf is induced in the loop. If the side length of the loop is 0.30 m...
Homework Statement
A block of mass m = 1.8 kg starts at rest on a rough inclined plane a height H = 8m above the ground. It slides down the plane, across a frictionless horizontal floor, and then around a frictionless loop the loop of radius R = 2.0 m. On the floor the speed of the block is...
Homework Statement
A square conducting loop lies in the xy plane of an xyz coordinate system. The loop is in a uniform magnetic field that points in the positive z direction and is decreasing at a rate of 0.070 T/s. What are (a) the magnitude of the induced EMF in the loop and (b) the direction...
Hello, I haven't used the for loop in Java much, so I have a question. How do you put multiple statements inside the initialization, condition, and iteration portions of the for loop?
I was coding and I came across this error:
Exception in thread "main" java.lang.Error: Unresolved compilation...
Question: If the Radius of the loop-the-loop is 10meters, from how high above the ground should the object be dropped in order to successfully complete the loop, with friction?
I attempted to solve it, but get the integral of cos(theta)dx, or more properly ds, and i do not know how to...
Homework Statement
So, I have a program, which I am finishing but I apparently ran into a problem. In the program I have to make that whenever I enter a 0 in the input, the program will stop and print the results. Here's the program before I continue saying anything else:
The Attempt at a...
I am trying to calculate what the heat change from room temperature is in a wire loop is. I have the power P, the thermal conductivity K , the radius of the wire "a" and the radius of the loop "r". Using Fourier's Law:
P = -KA \frac{\Delta T}{\Delta x}
I am unsure what to use as A and...
Imagine a closed loop of fiber optics, How long will a photon be able to stay inside the loop before dissipating all it's energy, or does it not dissipate?
Homework Statement
(Not this exactly, but it gets the idea across)
I have a square loop of wire with sides L and at t=0, I have the bottom side of the loop right above a uniform magnetic field. So the flux is 0 at t=0, and right when I drop the loop, it is forced downwards at a magnitude...
Hi there,
I have set up a flow loop for a uni experiment that will teach other students about the bernoulli equation. The loop will use a few working section that will increase and decrease pressure due to diameter, velocity and height changes.
I first set-up my loop with the pump at the end...
Homework Statement
A current carrying wire is bent into a circular loop with radius R and lies in the XY plane. A uniform magnetic field in the +z direction exists through out the plane of the loop. What is the magnetic force exerted on the loop?
Homework Equations
Fb = I lb sin (theta)
The...
Homework Statement
The figure shows a cylinder of mass 3.38 kg, radius 5.20 cm and length 8.12 cm with 70 turns of wire wrapped around it lengthwise, so that the plane of the wire loop is parallel to the incline and contains the axis of the cylinder. What is the least current which while...
Homework Statement
At one point in a roller-coaster, a single 300 kg car goes around a vertical, circular loop with a diameter of 24 m. It enters the loop at the bottom with a speed of 20 m/s. What will its speed be at the top?
Homework Equations
Kinetic Energy = 1/2mv^2
Gravitational Energy =...
(Sorry, meant to post this in Introductory Physics Homework, if someone could please move it.)
1. Homework Statement
Use Kirchhoff's Loop Rule to solve for the voltages of the five capacitors in the network shown below.
Homework Equations
For Capacitance, C = q/v
Kirchoff's juction law...
Homework Statement
Determine the input resistance using blackmans impedance formula.
I know all the ressisor values, and transistor data.
Homework Equations
[/B]
Blackmans impedance formula
The Attempt at a Solution
Our teacher has given us a example on how to find the open loop gain, but...
Homework Statement
Calculate the magnetic field of a current loop. Compare your numerical results with exact solution above the center of the loop. Investigate the effect of the grid size based on this comparison.
Homework Equations
dB = u0*I/4pi * (dL * R) / (R^2 + Z^2)^3/2
Bz = u0*I*R^2/ (2...
Homework Statement
I need a program (in PYTHON), which would ask a user his name and grade, then print them both. 1) If the name has a number it, the program has to ask the same question again until the name is entered correctly 2) The same with the grade. If it's higher than 10, the program...
Hello everyone,
Just posting this because I was wondering if it's possible to build 5-10km deep closed loop geothermal power plants from microgrid sizes of 1-5MWe to commercial power plant sizes of 0.5-1GWe that can have construction costs in the $3,000,000 per MWe range (similar to solar and...
1. Homework Statement
A small mass m slides without friction along the looped apparatus shown in the attached file. (a) If the object is to remain on the track, even at the top of the circle(whose radius is r), from what minimum height hm must it be released(from rest)? (b) If it is released at...
Homework Statement
A magnetic field passes through a circular loop of radius 14 cm and makes an angle of 65° with respect to the plane of the loop. The magnitude of the field is given by the equation:
B = (1.25t2 - .500t + 4.00)T.
a) Determine the voltage induced in the loop when t = 2.00 s...