Questions tagged as 'while'

2
answers

Why use while (0)?

In the Linux code I saw some macros with: do { }while(0) Is there a reason? Because apparently there is no logic to a loop of repetition where the code repeats only once.     
asked by 13.08.2015 / 21:13
3
answers

What is the usefulness and importance of "do ... while"?

The while command is a repeating structure with a condition at the beginning of the declaration. Example:    while (condition) {         sentences to run   } Already do... while has verification at the end, ie, the repea...
asked by 06.08.2015 / 15:22
8
answers

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...
asked by 05.05.2015 / 21:47
3
answers

What is the purpose of while (0) and while (1) in C?

What is the purpose of this? While(0) or While(1). The 1 verifies that it is correct and the 0 that is wrong? Why?     
asked by 17.12.2015 / 03:40
4
answers

What does the "do" function do in JavaScript?

I searched a lot and could not find the functionality of do in JavaScript. Example: function b(a, b) { do a = a[b]; while (a && 1 !== a.nodeType); return a }     
asked by 07.07.2017 / 15:42
3
answers

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<...
asked by 10.12.2015 / 19:00
4
answers

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(...
asked by 08.02.2017 / 18:28
1
answer

Retry user and password attempts

I wanted a program that checks the user and password, if it was correct to display a message, if it repeated the check and if the attempts were equal to 3, it showed the limit message of attempts reached. #include <stdio.h> #include <...
asked by 02.05.2016 / 13:32
3
answers

How to make the first two numbers of a Math.random sequence are not EQUAL

I made a lottery system in order to learn, I will not post the whole code here just the part that I am packed. It is as follows: The draw of the PC is a sequence of 6 numbers that I present in the DOM (it does not matter), so I want the first...
asked by 05.10.2014 / 07:02
1
answer

What is the purpose of the while (* variable) and if (! * variable) in the "while" and "if" statements?

In the Code Review there is a implementation of a simply linked list
asked by 08.11.2016 / 00:02