Most voted "loop" questions
Loops are a type of flow control structure in programming in which a series of statements can be run repeatedly until some condition is satisfied.
Learn more…671 questions
Sort by count of
-
3
votes2
answers133
viewsLoop Loop C# Asp components
You’d have to do a loop loop in this case? PaperBLL paperBLL = new PaperBLL(); List<PaperEO> papers = paperBLL.SelectPapers(); HyperLink1.ImageUrl =…
-
3
votes2
answers300
viewsLoop with "for" in a form with equal field sets
I have a data capture of a form where are fields 5 sets of equal fields. I want that at the time of capturing for my array, I do not need to repeat: array[1] = post1, array[2] = post2 I know you can…
-
3
votes2
answers2395
viewsAdd <option> to <select> with jQuery via $.post’s callback
I’m making a select that will have some users and when selecting a user will send a request $.post to get all records related to the selected user. After returning the related entries, the jQuery…
-
3
votes4
answers535
viewsMultiplying values within a for
I’m using the for to generate a loop of 4 repetitions! Inside this loop I do a simple numerical multiplication. <?php echo "Resultado: "; for($loop = 1; $loop <= 4; $loop += 1) { echo ($loop *…
-
3
votes1
answer904
viewsShare count and facebook likes in wordpress loop
Next I’m trying to put only a count of the shares I had on Facebook on loop of my theme. For this I found the following function and tried to modify it to my need. Follows the function: function…
-
3
votes3
answers933
viewsHow to remove the last character, store the result in a variable and use the variable outside of foreach?
I have a code PHP thus: foreach ($rows as $obj) : $all_ids = $obj->ID . ', '; endforeach; .. whose exit is 125, 148, 157, 169, 185, How to remove the last comma and store the rest of the output…
-
3
votes1
answer502
viewsHow to catch the key in a while loop?
Let’s say I have an associative array $array=array( "teste" => "1". "teste2" => "2" ); foreach($array AS $key=>$arr){ echo $key; } how does loop? has some way?…
-
3
votes2
answers113
viewsproblems increasing decimal place within loop for
var iniciaEm = 0; var terminaEm = 20; var variacao = 0.1; var s = ""; var str = ""; for(var i =iniciaEm; i<=terminaEm; i=i+variacao){ str += i; s += "<option…
-
3
votes1
answer288
viewsHow to make a foreach loop with limit in c#?
How can I make a limit foreach loop, for example I have a dictionary with 100 items and I want to make a loop of item 20 until 50 as I can do this in c#.
-
3
votes1
answer384
viewsConcatenate in loop with jQuery
I need to concatenate with jQuery all input values that have classes that start with "item_". I’m using the function below but it didn’t work. $(document).ready(function() {…
-
3
votes2
answers108
viewsScript to open index.html from multiple folders
How to make a script in bash that: Based on this example url: http://www.exemple.com.br/1/43530/12620/index.html Select the folder 12620. Open the index.html of this folder in a Firefox tab in Kali…
-
3
votes1
answer206
viewsCheck current index and next index equal to zero python
I need to scroll through a list in Python as for example: l = [2313, 1221, 1333, 66, 0, 0, 0, 0] I would like it if the current element and the next on the list are zero replaces the current and…
-
3
votes3
answers363
viewsJavascript function does not respect loop conditions
Good afternoon, I’m new here and I’m using the Javascript Scratchpad of Mozila Firefox to execute codes Javascript. It will really meet my needs, however the stop condition of the while loop is not…
-
3
votes2
answers91
viewsUsing a variable as a C file name
I’m using the function system("pathping xxx.xxx.xxx > c:\i.txt") to leave the program doing tests pathping and saving the result in a file to analyze later. Basically wanted to play this role…
-
3
votes1
answer1289
viewsForeach with Lambda does not work
I have a list of objects I want to go through, but it’s giving error and I’m not understanding why: listaAtendimento.stream().forEach(atendimentoFicha -> {…
-
3
votes1
answer1666
viewsLooping jquery setInterval
I’m doing a slider and I need that when the images finish passing, they start again but I’m not getting it. Someone could help? JS $(function(){ // Buttons Hover Effect buttonsHover(); function…
-
3
votes2
answers202
viewsDisplaying certain vectors in a 2D Python list
I have the following situation: - I have a variable called (vector_distances). This variable receives a 2D list with several vectors. - I wish it to be displayed, only vectors whose sum of their…
-
3
votes2
answers481
viewsDoubt of C++ loop do-while
Good people, I have the following question: Every time I run that program the do-while loop doesn’t stop at the second loop scanf in the program and ends up running twice and displaying the error…
-
3
votes1
answer530
viewsInfinite loop, object orientation
Well, I’ve been doing some research, I found several topics talking about it, but none of them were useful to me, so I decided to turn to Stack Overflow. I have a role to list all user tickets that…
-
3
votes1
answer49
viewsLogical error no for
Hi guys I’m trying to make a controlled loop for my program, so far it’s running normal only in the first round, in the second repeat it jumps the first pass of the go and starts in the second…
-
3
votes1
answer163
viewsIn a matrix Z of elements (i,j) how to assign the value 1 when i=j? (software R)
Under the following condition: ifelse(??, 1, Z/(1+1)) What to put in place of "??" so that R understands that when i=j in the matrix Z, I want to assign the value 1?…
-
3
votes2
answers726
viewsCreate sequential counter
I need to create an occurrences count column of a value present in another column. For example, counting in column "y" of elements present in column "x": x y 1 A 1 2 B 1 3 A 2 4 C 1 5 B 2 6 A 3 I’ll…
-
3
votes3
answers94
viewsHow to reference the first loop from the second in a chain of loops?
In PHP, how can I reference the first for from the second, as in the example below? for ($i=0; $i < 10; $i++) { for ($j=0; $j < 10; $j++) { // Quero que esse afete o primeiro `for` e não o…
-
3
votes1
answer180
viewsVariable with unassigned value within a "for" loop
int i; string cpf; cpf = "11111111111"; DbConnection cnx = ADO_Utils.GetConnection(); DbCommand cmd = ADO_Utils.GetComando(cnx); cmd.CommandType = CommandType.Text; for (i = 1; i <…
-
3
votes2
answers74
viewsHow do I stop "for" when I find an item in the list?
I have the following code: Console.Clear(); Console.Write("Nome da moto:"); string nomem = Console.ReadLine(); for (int i = 0; i < ListadeVeiculos.Count; i++) { if (nomem ==…
-
3
votes2
answers97
views -
3
votes1
answer508
viewsBreak java loop
My project in Java is a lighthouse control with Arduino. Up to there everything right. However I made a function in which the leds is automatic in a loop after a RadionButton be selected. My problem…
-
3
votes3
answers4140
viewsFunction that calculates the factorial of a number
int fatorial(int n, int f){ int resultado; while(n>1){ f=1; resultado=(n*f); f=f-1; } return (resultado); } int main(void){ int resultado; int n; int f; printf("Digite o numero a ser…
-
3
votes2
answers144
viewsRecursive printing in triangle format
I have to read an integer value and pass it as a parameter to a function. It should display the number using the sample format. Ex: if the number given was 3, show: 1 1 2 1 2 3 I can show the format…
-
3
votes1
answer3361
viewsLoop for inside loop for
for(pass = 0; pass < size - 1; pass++){ for(j = 0; j < size - 1; j++){ if(array[j] > array[j + 1]){ swap( &array[j], &array[j + 1]); } } } I put only a piece of code where I have…
-
3
votes1
answer112
viewsRepeating structure
I’m studying repetition structure in Java here. And I came across the will to do the following: public class Teste { public static void main(String[] args) throws IOException { for (int i = 1; i…
-
3
votes1
answer385
viewsI’m not getting loops while nested
I’m having trouble understanding this code, because I don’t understand how it behaves in loops while, follow the instructions after the code. Note 1: I am learning programming logic yet, so I am…
-
3
votes1
answer64
viewsLoop command to group values from a database into a new list
Good afternoon, everyone! I’m starting in R (starting well) and tried to make a script to solve a simple operation that, however, was performed entirely in excel during a mini-course I did, giving a…
-
3
votes1
answer85
viewsIs there a loop loop behind the code of a CTE?
I’m racking my brain to understand how such a simple command can generate values from 1 to 100. Is there a loop behind a CTE? For in the code below there is a loop WHERE and not a WHILE. WITH…
-
3
votes1
answer408
viewsHow to extract space-separated words via Javascript
Continuing the marathon of articles regarding the extraction of texts, I noticed that this type of question is very difficult to find next to a clear and direct answer. In order to remove my doubt…
-
3
votes1
answer45
viewsLoop with R arrays
I need to create a matrix that has all the coordinates for a 128x128 matrix in R if it were a 3x3 matrix, ex: 1 2 3 1 a b c 2 d e f 3 g h i I would need the following matrix x y 1 1 1 2 1 2 3 1 3 4…
-
3
votes1
answer129
viewscalculate percentage of iterated items in a loop
How to get the percentage of total items in an array that have been processed in a loop? Example: // array fictício (238 itens) var arr =…
-
3
votes3
answers138
viewsIs it possible to use for loop to reduce C code?
I have the following function:To. It is possible to use for loop B to generate the declarations as in the function To? What to wear instead of printf to become a declaration?…
-
3
votes2
answers259
viewsOptimization of multiple ifs into something more practical
I have a string alphabetical: char string[] = "aouihuiahsudasduihqmdoiqjnduiamsdoqnwuidamodkjwodkaposdj"; I want to go through it all and for every character of it, say how many times it repeats in…
-
3
votes4
answers744
viewsHow to get the highest and lowest number among 15 typed numbers? C++
An algorithm that reads 15 real numbers, and writes the largest and the smallest among the numbers read. I’m not getting to do the part of writing the smallest and largest of the numbers typed.…
-
3
votes2
answers280
viewsLoop is not repeating as it should
I am creating a code that reads the number typed by the user and, if it is from 1 to 10, it performs the tabulation, presenting value to value on the screen, besides allowing the user to choose…
-
3
votes4
answers167
viewsHow to return the first vowel of several words in a list?
The code is partially done, but it returns only the vowels found in each word. How could I return only the first vowel of each word? palavras = ('boi', 'vaca', 'macaco', 'ovelha', 'lesma',) vogais =…
-
3
votes2
answers1405
views -
3
votes2
answers565
viewsImproper Infinite Loop no while
I made a program to calculate within a sequence the sum of the positive numbers and the sum of the negative numbers. When I use the command while, the idea is that it is within a sequence of 7…
-
3
votes2
answers460
viewsRecursive or loop method to popular or list an n-dimensional array
I’m trying to build a method capable of filling an n-dimensional matrix in all positions, for example: I have a 2-dimensional matrix, where this matrix is 2x2 with only 2 dimensions in a Cartesian…
-
3
votes2
answers1419
viewsCreate and assign loop variables For
How to make this logic within a loop FOR ? var G1 = $('#G1').text() var G2 = $('#G2').text() var G3 = $('#G3').text() console.log("NaN") console.log(G1+"\n"+G2+"\n"+G3) console.log(G1+G2+G3) G1 =…
-
3
votes1
answer84
viewsEliminate code redundancy in a while loop
In this example: . Request today’s date via a form. . Check if typed in dd/mm/yyyy format. . Compare to current system date from datetime import date def verificacaoData(): dataForm = input('Digite…
-
3
votes2
answers69
viewsFor loop build error
I’m making a program that asks how many notes the user will type and after that, enters a 'for' loop asking what are the notes to type. Notes are stored in a array and finally the average. #include…
-
3
votes1
answer129
viewsHow to make a recursive sum on a JSON object in Angular 6?
Using Angular 6, how could fill the field total representing the total number of direct and indirect bosses of each employee? I have the following data: const employees = [ { id: 1, firstName: 'a',…
-
3
votes1
answer85
viewsArray always getting the same value [Loop in two matrices simultaneously]
My program scans an image and assigns color values R,G, B the variables that were compared with matrices containing the colors R,G, B asphalt and earth called auxAsfalto and auxTerra. The point is,…