Questions tagged as 'for'

2
answers

Print the result of a for JS within a p

I'm doing a college job that consists of making a tabletop generator. It is working perfectly when I use console.log to show the result, but when I use .innerHTML = resultado to show on a <p> tag it only shows one l...
asked by 08.11.2018 / 23:30
1
answer

What is it and how does it repeat in C #?

for (int i = 0; i < palavra.Length; i++) What does each word mean? And how does each part of this code work?     
asked by 15.09.2017 / 13:04
4
answers

Interpretation of repetition loop

I'm having trouble understanding the following code that is presented as a book exercise. $a = true; $b = -2; $c = 7; for ( ; $b < $c || $a; $b++){ if ($c + $b * 2 > 20) $a = false; echo $b." "; } The result is: -...
asked by 10.10.2018 / 00:58
3
answers

Generate random numbers in an Array of 10 up to 50

How can I generate an array of random numbers with a limit, must be numbers from 10 to 50. To generate random numbers from 0 to 50 I use: Random random = new Random(); int array[] = new int[5]; // 5 números serão ger...
asked by 25.08.2015 / 16:58
3
answers

Behavior difference between for and for..in

I have the following code that works exactly as expected (that is to go through the array, showing ONLY each element, in this case "Miguel" and "Celeste"): var runners = ['Miguel', 'Celeste']; Array.prototype.winner = function() { for...
asked by 15.12.2016 / 11:55
1
answer

Why is a FOR of the loop faster than 10 FOR together

I made a for alone count to 1000000 (sending 1 message to each loop ) and it took 14 seconds. public class main { public static void main(String[] args) throws InterruptedException { long init = System.currentTimeMillis();...
asked by 07.07.2015 / 03:46
2
answers

Is there any difference between an infinite loop with for and while?

In PHP, you can generate an infinite loop with while simply by passing the true parameter. Example: while (true) { echo "Ao infinito e além"; } It is also possible to generate this through for , simply omittin...
asked by 01.10.2015 / 22:55
2
answers

How to create a for in R with the indexes of a data frame

If I have a data.frame: > dato<-as.data.frame(matrix(1:64,8,8,T))[-3,] > dato V1 V2 V3 V4 V5 V6 V7 V8 1 1 2 3 4 5 6 7 8 2 9 10 11 12 13 14 15 16 4 25 26 27 28 29 30 31 32 5 33 34 35 36 37 38 39 40 6 41 42 43 44 45 46 47 48...
asked by 01.05.2018 / 16:15
1
answer

How does for (?;) work?

It's probably duplicated, but I did not find it here in SOpt, and I do not know how to search on Google. How does the for loop work in this syntax? for(;;) { //... }     
asked by 20.10.2017 / 18:29
4
answers

Loop run every 20 lines

I would like every button click to count, and it would invoke variavel to change the initialization and condition > for , for a numeric value of 20 in 20 . It would be kind to go from 0 to 20 and wait another click. On a...
asked by 05.05.2016 / 17:12