Most voted "while" questions
Use this tag when the question primarily involves logic and/or command structure. Effectively, while is a repeat loop used to iterate matrices, vectors, or to another end that basically has a single component, the stop condition.
Learn more…332 questions
Sort by count of
-
0
votes1
answer42
viewsLogin: Mysql search returns only one object
In a login system, I take the e-mail and password given by the user by a form and see if there is any identical information in the database. $conn = new mysqli("localhost", "root", "", "prisma");…
-
0
votes1
answer80
views -
0
votes1
answer66
viewsForce user to enter integer numbers in an array
Person, what would be the best structure to force the user to enter positive integers within an array (array), the code fragment I copied here is inside a function, it works ok when first executed,…
-
0
votes1
answer89
viewsRun SQL Query multiple times between two dates (MYSQL)
I wonder how I do to run an SQL query between two dates where for example: the user will choose two dates: starting date = 20/04/2020 final date = 25/04/2020 so I wanted to know how do I do to do…
-
0
votes1
answer262
viewsI need help creating a game like 21
I am working on a game type 21, and I am struggling to create a logic so that the values that the user receives through a draw with random.choice are stored in a list and soon after I display the…
-
0
votes1
answer80
viewsConvert for to while
#include <stdio.h> #include <stdlib.h> int main(void) { int X[10], cont; cont=0; while(cont<10){ printf("Digite um numero inteiro: "); scanf("%d",&X[cont]); if(X[cont] %2 == 0){…
-
0
votes1
answer137
viewsHelp with While in Java
I’m starting in Java and I was left with a question about how to insert a While loop in the code below. It’s a simple code I’m doing to practice, but I can’t seem to create While in it. I would like…
-
0
votes2
answers56
viewsLoop "while" ending earlier than expected
The question says the following: Write a program that reads the side of a square and then print the square with asterisks. Your program should work with squares of all sizes between 1 and 20. For…
-
0
votes0
answers47
viewsAccentuation in printing and blank fields
Good people, I am just about to explore the world of Velopers, so I will need a discount for the many mistakes in my little program. I didn’t find an answer here, so I’ll ask. The program below…
-
0
votes3
answers380
viewsLoop to determine the smallest entered value
I’m having trouble creating repetitions to get the lowest value out of a given situation. For example, a program that registers price of products in which I have to report the lowest value and the…
-
0
votes1
answer184
viewsHow to get the program out of the loop
In the exercise I am doing, it is asked that when the number of repetitions is 0, finish the execution, but when I type 0 it does nothing and continues to read numbers. It reads a number K of…
-
0
votes1
answer85
viewsWhat code do I put with the while?
I want you to have a loop when typing the number for "yes": while(resp.equals(cont)) and while(!1.equals(cont)) . import java.util.Scanner; public class umm_whilezinho { public static void…
-
0
votes1
answer41
viewsProblems with append incremetando until the infinity in Python
I’m doing a program that scans 35 bits on a piece of equipment, storing reference bits in an array. The logic to know if any bit has changed since the last reading, always saves the previous result…
-
0
votes0
answers42
viewsDuplicate the last line of the file . txt c++
#include <fstream> #include <vector> using namespace std; struct Produto { string nomeProduto,quantidade,marca,preco; }; void carregaProdutos(vector<Produto> &R) { ifstream…
-
0
votes1
answer43
viewsDoubt about while loop on C?
I need to know why 0 has to be typed twice in order for the program to stop traversing the loop. And the same thing happens when I use the do-while. #include <stdio.h> #include…
-
0
votes1
answer111
viewsPython - Square root estimate
Good, I was here solving an exercise where the program asks the user for a positive number and calculates its square root using: +=(+ã/) / is an estimate for the square root of the number; + is the…
-
0
votes4
answers91
viewsHow to transform a "for" repeat code into "while" in Javascript?
var ordinais = ['primeira', 'segunda', 'terceira', 'quarta']; var media=0; for (var i = 0; i < ordinais.length; i++) { var nota = prompt("Informe a " +…
-
0
votes1
answer70
viewsPython: Problem with random numbers within while
I would like to know how to solve a small problem I am facing in this and other codes. When testing the example you will realize that it will use the same atk always, that is if he chooses the atk…
-
0
votes1
answer54
viewsHow to handle errors if the user enters an invalid character?
I wanted to do in the notes entry part, and in the final part of showing each student’s grades individually, something similar to what I did in the 'Want to continue? [S/N]', that is, only step…
-
0
votes1
answer72
viewsWhile doesn’t display if I use get id?
Can someone help me understand why this code is failing to display the genre of the bank? <div class="first_info"> <?php $vide = $_GET['i']; include "core/home/database.php"; $consultaGe =…
-
0
votes0
answers35
viewsC# - Cascade Repeat Structure
first good morning! I have a task to feed a "file tree (windows explorer style)" in object format. For this I have initially a method that lists all the files and folders in the directory root of…
-
0
votes0
answers74
viewsAnd python how to stop a specific thread (or all) in while loop
How to stop one, or all threads in python by ID (example) I’m developing a program that should run some loops looking for information in real time. However, when any of them find something the…
-
0
votes1
answer366
viewsCompound interest in Python using "while"
Recently I was trying to solve an exercise to learn Python, but I found big problems when I tried to calculate compound interest. I used the mathematical formula of the amount and simply I have no…
-
0
votes1
answer58
viewsDo-while with char in C
EX. Create a program that reads sales values (old and new) of a product. The program must calculate the percentage increase of the product. The program ends only when the user informs the letter "N"…
-
0
votes0
answers36
viewsHow to resolve Signal: Segmentation fault (core dumped) in C++
I’m trying to make a noose and on that part, always gives the core error dumped. how can I solve this problem? cout << newnome1 << ", ESCOLHA UMA PALAVRA: "; cin >> palavraSecreta;…
-
0
votes1
answer28
viewsTake an input value and play value in another input by Javascript
Good evening, I would need the user to choose how many classes you want in select and then the system will calculate the value and put in the other input, I don’t know where I’m going wrong if you…
-
-1
votes1
answer1359
viewsReplace wrong words in a Text Box
I wanted an idea of how to create something of the type, text field, where we type some wrong word(s) and soon is corrected(s). For example: <body><input type="text" id="exibir"…
-
-1
votes1
answer422
viewsHow to invert the order of loop results in PHP?
I wrote a code based on tutorials I saw to show User Comments Database information in tables but I would like it to reverse the order of the results. How can I do that? <?php // se o número de…
-
-1
votes1
answer23
viewsLoop(For) doubt with information coming from the database
E ae personal blz ? I’m having a big problem executing a code of my own. I have a web application made in Windows, which is running locally. In this application I need to generate a report that is…
-
-1
votes3
answers516
viewsVariation of while with scanf
What does this piece of code mean? while(scanf("%d", &variavelA) && variavelA )
-
-1
votes3
answers2192
viewsPut only True and False in if and while
I wonder what that’s for: if true: #Código or if false: #Código or while true: #código etc..…
-
-1
votes1
answer285
viewsProblem with switch inside the While loop
I would like a help to solve the problem I’m having with the switch inside the loop, it never finalza, stays in an eternal loop. What should I do to solve ? #include <stdio.h> #include…
-
-1
votes3
answers145
viewsSame codes, different outputs
Why in the code x = 1 while (x < 4): x = x + 1 print ("x vale", x) has only one output 4, and in i = 6 while (i > 0): i = i - 3 print (i) The way out is different.…
-
-1
votes1
answer174
viewsI need to count the prime numbers to a certain number n
Write the n_primes function that takes as argument an integer greater than or equal to 2 as parameter and returns the number of primes that exist between 2 and n (including 2 and, if applicable, n).…
-
-1
votes1
answer62
viewsExit "while" by filling lists
I need to make a code that uses while and lists, which aims the user to register an undetermined number of people while he wants and put 0 to finish and show on the screen the created list. It is…
-
-1
votes2
answers161
viewsTerminate program with enter/ EOF
I need the code to end after an empty enter, with no input or the 'EOF', but I don’t know how to apply it and I didn’t understand very well the examples I saw. The program is almost complete, it…
-
-1
votes3
answers174
viewsPython - Sine cycle in degrees
Good in order to calculate the sine cycle (sin) in degrees between 0 and 390 with an interval of 10. print('Ciclo seno em graus entre 0 e 390 com intervalo de 10') a=0 while True: if…
-
-1
votes1
answer725
viewsGrab clicked client id and write to a variable to recover in a modal
My PHP code has a while that lists registered users, from a query MYSQL. This list of users shows the photo, the id, the name and a link to open a modal. Follow the code of while: <?php…
-
-1
votes1
answer91
viewsNull input via keyboard in a variable receipt via Javascript
Good night! In my practical Javascript experiences, I tried to create a condition to alert the user about a variable he missed by pressing the key enter twice. However, in trying to solve this…
-
-1
votes2
answers225
viewsKeep while information in variable
I have a code where you have a while within another, to be able to list products within the shopping cart divided by stores. Logo, to see listed the products, as in image 1. As in the picture above,…
-
-1
votes2
answers39
viewsShellscript for returning bank values each value in 1 different variable?
Hello I am trying to return 1 value for each variable I can return however, I am trying to create a condition that applies to one for which are true and which are false and display me on the screen…
-
-1
votes2
answers1396
viewsLoop inside loop While PYTHON
I’m making a program that draws a number from 0 to 5 and the user should guess what it is, but he only has 3 attempts. In case the 3 attempts run out and the user does not guess which is the number,…
-
-1
votes1
answer65
viewsHow to make the program continue where I left off after an exception happens in my Ry
In this excerpt I got the expected result, which was not close the program after the error message if the user enters with wrong data. However, even if I’m in the 10th, it resets to the first. So…
-
-1
votes1
answer85
viewsI have a problem with the beginner python code
Good afternoon! I’m a beginner and I’m trying to learn python, I tried to make a program that calculated if the number typed is prime and then the program asks if I would like to calculate all the…
-
-1
votes1
answer46
viewsProblem executing function with While loop and If condition
I need to perform an exercise, which prompts a system that reads 20 numbers, then sums them up and then displays the result on the screen. The statement asks to use only While. So I made the code…
-
-1
votes1
answer80
viewsShow all possibilities of Python numbers
How do I show all possibilities according to the number of bit quantization, for example: user: 8 levels bits: 3 need to show then: 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 my code so far,…
-
-1
votes1
answer59
viewsRepeat codes with while loop
I’m having trouble executing a noose while within another while. I used the code below, which does everything right, but at the time I type 1 it only repeats the question "Do you want to repeat?…
-
-1
votes2
answers71
viewsInclude single board values and show this on the screen without having to repeat boards
How do I print a coordinate without printing multiple trays with the values I typed on the board? tabuleiro = [[0 for x in range(0, 10)] for o in range(0, 10)] print('------------------') print(' a…
-
-1
votes3
answers300
viewsHow to use while and if in Python?
Forgive me if it’s a stupid question, but I’m a beginner. I have to use the while condition to finish the program. In this case, the code has to rotate while the weight is different from 0. And, if…
-
-1
votes1
answer56
viewsReturn in while - PYTHON loop
I’m starting to learn python now and I’m still lost in the syntax. In the following program I do not know what to do to restart the program, ie, return to the beginning if the user type "yes" or…