# Questions tagged as 'for'

8

## Difference between while and for

What is the difference between while and for , if both are loop repeats, if with both I can do the same things either condition a stop or variable iterations because there are both. My question is: Is there a way to demonstrate...
2

## For with a ";" at the beginning of the loop, which means

I got a code with a for: for (; indField > 0 && indMask > 0; ) What does this ";" mean at the beginning and end of the command?
2

## How does the "for" inline command work?

I did a question regarding a Python algorithm, but in resolution of the user Anderson Carlos Woss he used a type of% inline that I had never seen and that left me confused. Here is the code snippet corresponding to for : groups...
3

## How to calculate perfect numbers quickly?

I'm trying to perform an exercise to show the perfect numbers present within a given range, but I can only do this to the perfect fourth number. If I increase the range, it takes a long time and does not respond: def perfeito(n_max): lista...
3

## Which loop is faster in C: while or for?

Being a loop while and a for that rotate the same number of times, which is faster? Example: while : int i = 0; int max = 10; while(i<max){ funcao(); i++; } for : int i; int max = 10; for(i=0; i<...
4

## What would be a good way to apply events: onMouseOver and onMouseOut, for all img tag?

I need this function to be automated so that it applies to all images made on the HTML document without any exception Code function aumenta(obj) { obj.height = obj.height * 2; obj.width = obj.width * 2; } function diminui(...
2

## C ++ (basic): for, references and syntax

My teacher introduced this role to us: void escala(std::vector<double> &v, double fator) { for (auto &vi:v){ vi *= fator; } } It serves to multiply all elements of a vector by an already predefined factor. I h...
2

## Why is this loop "for" not infinite?

public class Loop { public static void main(String[] a) { int cont=0; for (int i=0; i>=0; i+=2, cont++); System.out.println("cont:"+cont); }} I was struck by the condition of the loop for i>=0 . At the time I thought: loop infini...
2