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
-
1
votes1
answer69
viewsBlock Prints
The programme should: receive a 4 digit number, sort and keep, sort downward and save. Subtract increasing to decreasing and save so that the process starts again until subtraction equals 6174. I…
-
1
votes1
answer101
viewsn >= 1 in the while condition returns no value
Good night. I’m starting to learn Java and I made a program with swing that calculates the factorial of a number. I did using while, and in the condition, I tried to do with the condition (n >=…
-
1
votes2
answers233
viewsVariable is not being found
Why the following program does not work? package javaapplication1; import java.util.Scanner; public class Exemplo008 { public static void main(String[] args){ Scanner teclado = new…
-
1
votes1
answer1113
viewsProblem with switch menu case and while
My goal is that after I run one of the menu options and say I don’t want to continue on it, I can insert another option (or the same if I want to go back). My code runs the first option I type but…
-
1
votes1
answer113
viewsHow can I get a program shut down by typing an empty space (' ') into python
How can I make a repeat loop while stopping when the user inserts a blank space (" ")? I tried to do so: while num != '': num = int(input("Insira um número: ")) But the variable is not an integer,…
-
1
votes2
answers80
viewsHow do I use the for command to solve the same problem?
In this case, the objective of the program was to make a half pyramid, as many floors as the user wanted to build, however, he wanted to use the 'for' command to accomplish this goal. quant =…
-
1
votes1
answer754
viewsHelp with While loop in Python
I have tried several times, I can print the largest amount, I can print the date of the biggest sale, my problem is at the time of the loop, code follows the loop as this in command, only when he…
-
1
votes1
answer37
viewsCreate loop and move to arguments of a function?
I have the following code in Python: storage.tableWidget.setColumnWidth(0, 30) storage.tableWidget.setColumnWidth(1, 140) storage.tableWidget.setColumnWidth(2, 90)…
-
1
votes2
answers168
viewsWould you like to make a code that spells out the word?
I’m new to programming and I’m trying to put together a script where I type in a word and he spells it out for me! I’ve assembled the following code! nome = input('palavra para soletrar:') while…
-
1
votes3
answers80
viewsDisplay only one message at the end of an operation within a WHILE
I have a situation. I do a search in a table and from the returned data, insert in a new table and update the current one. Ex: $busca = $link->prepare("SELECT valor FROM tabela1 WHERE funcionario…
-
1
votes1
answer131
viewsHow to open different web pages using while
I would like the program to perform the repetition of a command 3 times: wait 10 seconds to open a web page. For this repetition to occur I set the code below: import time import webbrowser…
-
1
votes0
answers20
viewsWhile problem in java (simple exercise)
Context: I’m making an algorithm that stores random strings typed by the user in a string array until the user type "stop". problem: when typing stop, the eclipse continues the loop in while, and in…
-
1
votes3
answers385
viewsThe same variable repeats several times in the while
In the while words are appearing several times, example: macarrão macarrão macarrão macarrão macarrão macarrão arroz arroz arroz arroz arroz arroz What am I doing wrong? <?php…
-
1
votes0
answers330
viewsHow to use while on Tkinter to make Par or Odd game?
I’m starting now and so I’m super lost, this and my code: from random import choice from tkinter import * janela = Tk() janela.title("Jogo do PAR ou IMPAR!") fontPadrao = ("Arial", "10", "bold") def…
-
1
votes2
answers132
viewsHow to analyze the input in the while condition?
I am learning C, and as the language in which I was "literate" is Python, I usually make associations to better assimilate. In Python, I can receive a direct value in the while condition. Ex.: while…
-
1
votes2
answers150
viewshow to select items in while counter, in php
I created an admin page where I register the book data in the database. I made this html where this data will be shown. the matrix will create this block "cabtitulo" with all the books registered on…
-
1
votes1
answer98
viewspython - strange loop
I’m almost done with my application. In the final moments of the code I’m locking into a loop that I can’t resolve. # O programa pede para o usúario inserir uma data no formato dd/mm/aa, # e efetua…
-
1
votes1
answer232
viewsSpecifying students height and sex with a "while"
The exercise asks me to read 20 students and their respective heights and gender, and then show the average height and how many men and women we have. What I did was this: int main() { float altura,…
-
1
votes0
answers49
viewsWhy is there an error coming at the end of a file that ends with blank spaces in a while loop, using the >>read operator?
I want to perform a reading function of a "material" vector (I created this type with "struct"). The reading will be executed from a file. std::vector<material> material_read(std::string s) {…
-
1
votes0
answers64
viewsdo a while loop or restart the program on Tkinter with new question
I would like to know how to do when click the reply button, restart the program with a new account and optimizing the code? from tkinter import* from random import randrange janela=Tk()…
-
1
votes1
answer799
viewsC / How to exchange for a while?
Write the function prints using the while repeat structure instead of for. If necessary I can edit and insert all the code. void imprime(Ccc *p) { Ccc *r; for (r = p; r!=NULL; r = r->proximo)…
-
1
votes1
answer275
viewsProblems with the 'continue' or 'while' command in Python
So I was doing some exercises in python, a language in which I’m learning to program, and it seems to me that the execution flow is not following correctly. # Converte distancia def mettocent(met):…
-
1
votes1
answer70
viewsTry-catch in loop causing error
I have the following code, which tries to click a button after 60 seconds, and if it has not pressed, try again after 60 seconds. while(true) { var timeout = setTimeout(function() { try{…
-
1
votes1
answer123
viewsDifference between algorithms that read numbers until receiving the number 999
What is the difference of these codes? First code: cont = 0 n = 0 total = 0 n = int(input("Digite 999 para parar")) while n != 999: n = int(input("Digite 999 para parar")) cont += 1 total += n…
-
1
votes2
answers1272
viewsStore all records of a table in a variable (PHP)
I need to make a query in my Mysql database and store all rows that are returned within the variable $dadosBrutos. The intention is that each line be separated by the character "§", for example:…
-
1
votes1
answer73
viewsSingle-line save in DB, the result of the PHP variable (WHILE/LOOP) of a MYSQL Query
I have the following problem: When performing a query, the while result is composed of more than one value, for example: $query_sku = mysqli_query($connect, "SELECT t.column_name FROM skus AS s…
-
1
votes1
answer94
viewsWhile() loop validation bug?
I’m trying to set the total of some values I capture in the Sqlite database, so far so good because the values passed in my Arrayadpter is set on the screen without major problems. The problem is…
-
1
votes0
answers47
viewsClass being added to only one loop (PHP) element
I’ve been developing a system for a while and in it I was implementing the LAZY LOAD, that famous technique of loading images that are only loaded when the user scrolls the page to where they are. I…
-
1
votes1
answer46
viewsHow to query a column in the database and view filtered in 3 html columns?
good morning. I have a question that I have never come across before with php and mysql. I have the following example table in mysql: ITEM : DEP : QTD ============================= 1 : T01 : 1000 2…
-
1
votes1
answer34
viewsQuestions about data listing!
Hello I am developing a project using the Mysqli extension, and in this taking advantage to use some object-oriented functions! I would like to ask a few questions regarding the data listing, are…
-
1
votes1
answer34
viewsLooping in a validation within a matrix
Well, I need to validate typed numbers so that my matrix matriz[5][3] accept only odd numbers, for this I used inside the loops for one do{ }while to have another number typed in case it was…
-
1
votes1
answer178
viewsRepeat rows from a table using Javascript
My question is the following: I have this code where it feeds a table with 3 fields (portion value, start date, end date). From my numerous attempts I have not had success I am trying by a while to…
-
1
votes1
answer139
viewsPHP/FTP File Verification
Hello, I have the following situation: My company wants to validate all files from a particular folder on FTP with BD (Mysql), to make sure that all files are being used and those that are not…
-
1
votes3
answers178
viewsWhile php creating div
I have a PHP code that creates div’s em while, but it took a lot of work to build it because we have to keep opening and closing quotes in the code, I wonder if you have the possibility to do the…
-
1
votes2
answers1434
viewsHow to make the user return the specified condition when the same type wrong?
In Python, when the user type a non-existent option, how do I ask him to type again one of the desired options? Make a program where the user can type several values and register them in a list. If…
-
1
votes0
answers24
viewsHow to display multiple messages of existing data on the PHP server
Hello, In this code I would like to display two existing data message on the server being the matricula (which already works perfectly) and e-mail. I’ve tried some ways to insert these two messages,…
-
1
votes0
answers39
viewsProblem with repeated data in PHP table
I have a doubt, when making a select to fill a field if it is equal to real it should fill ex: the item 1 in the value of 1 real the item 2 in the value of 2 and the item in the value of 3, however…
-
1
votes2
answers562
viewsHow to go through two lists of different sizes [PYTHON]?
The idea is as follows: Each team has 6 maps played (mapList) I made a web Rawler that takes all the information related to the team and the map and wanted to insert automatically in a spreadsheet…
-
1
votes1
answer54
viewsHow to extract strings from 4 different files, and insert into a single line of an HTML document
For hours I’ve been trying to find a way to include the contents of 4 distinct files for a new output file -; "output.html". The 4 files I’m looking to extract information from are: link.txt…
-
1
votes1
answer104
viewsHow to generate javascript functions within while
I am developing a Soundboard, and in this code, each <audio> is generated by record found in the database, and each of them has a volume controller, however, all controllers only work pro last…
-
1
votes1
answer68
viewsLogic expression that controls repetition
I’m solving a Python exercise that asks the user to give a guess, on what number the program got to pc randomly. from random import randint tent = int(input('PALPITE:')) pc = randint(0,4) cont = 0…
-
1
votes2
answers69
viewsMake sure the entry doesn’t happen again, numerically and within a range?
I am programming a game of old. When the user chooses the house where he will mark his symbol (X or O), I need to ensure that: The input value refers to an empty box (which has not previously been…
-
1
votes0
answers97
viewsCheck Dynamic Checkbox (Checkbox) from a while inside the database
Guys, I’m banging my head here with this... I have two tables in the bank, one corresponds to the department and another corresponds to the checkbox registered for that department, the problem is,…
-
1
votes1
answer50
viewschar returns invalid typed number as option
opa good afternoon, I am developing a menu in which the option typed is a char, the same returns the default correctly after typing a letter, however, my switch has 7 case options ('1',…
-
1
votes2
answers195
viewsHow to return a list where the size is set according to a number typed in the python input?
I would like the code I wrote to return a number of tuples according to the value entered in the input, for example, if the input is 3, the return will have to be 3 pairs of tuples. The following…
-
0
votes1
answer64
viewsProblem in the supply function
I’m here with a problem in this role int supre (char S1[ ], char s2[ ]) , which calculates the size of the largest S1 suffix prefix of s2. For example if you have supplied ("cheat", "totality") you…
-
0
votes1
answer67
viewsLoops do not keep values
Hello! I am trying to develop a simple program that does an automatic accounting calculation, however, the condition within the for(while, while, if / Else, either) does not maintain its values. The…
-
0
votes2
answers748
viewsWhile incrementing datetime field in MYSQL
I need to do a while between an initial date and a final date, that is, while the initial date is less than the final, will return a query, how can I increment this while to make it run?
-
0
votes1
answer90
viewsLoop error in stock control
<?php $sql = mysql_query ("SELECT * FROM cadastro "); while($resultado = mysql_fetch_array($sql)){ $idrepete = $resultado['id']; ?> #divId<echo idrepete; ?>{ width:100%; } <?php }…
-
0
votes1
answer70
viewsGroup results of queries
The process below makes one query per day between the initial and final dates, so it brings several queries, there is a way to group all queries generated in only one? And yet, how to eliminate the…