Most voted "logic" questions
Use this tag when the question primarily involves logical sense in the development or processing of an information-based application that, related to each other, imply an objective within an established rule.
Learn more…376 questions
Sort by count of
-
0
votes1
answer241
viewsExercise of programming logic
I’m still stuck in this programming world and I tried to solve a logic problem by myself involving the Fibonacci sequence. Unfortunately I did not succeed and after searching the internet, I found…
-
0
votes0
answers65
viewsHow to do an IF/ELSE SQL check
If anyone can help me, I really appreciate... I am beginner and I am not able to develop the following check: If substring (tasks, 9, 1) = S, it should delete only in the Startup tables If substring…
-
0
votes1
answer59
views(Java) Read TXT (input) and generate TXT (output) with organized information
I need to make the following logic: 1- Read a txt with several lines, each line has an activity EX: Walk 10min, Study 30min... (each activity in a row). 2- Half day lunch time. 3- Organize the…
-
0
votes2
answers44
viewsHow can I check if two values of two matrices are in the same position?
I am trying to create a mini login system using python, where a login and password are requested, and if the two match, for example: the login is at position 2 and the password is also at position…
-
0
votes1
answer60
viewsComparing strings to switch in PHP
The point is this: A company will give a salary increase to its employees from according to the category of each employee. The increase will follow the following rule: Employees in categories A and…
-
0
votes1
answer112
viewsI need help with my Roman number code (C language)
Well, I created this code as a draft form for the project I have in which it turns certain words into decimal values, but I did it with Roman numerals pq is easier that way for now, but there’s a…
-
0
votes1
answer443
viewsError '''Segmentation fault core dumped'' in C
I’m a little new, but I haven’t been able to solve that problem yet, so I came to you. I use linux and I have a problem with the code I made (it’s very simple). The code reads a number and…
-
0
votes1
answer39
viewsLoop adding repeated values
I have a loop inside a request, which adds an ID in an array, so that on the next repeat it checks if this same ID is no longer added. and if it is already in the array, skip to the next array id.…
-
0
votes1
answer179
viewsC code skipping user input
Hello! I am Newbie and I am trying to make a program to read a list of information inserted in it. Until the first line it works, but from the second register he no longer reads the name, putting…
-
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
votes2
answers396
viewsHelp with logic - Portugol Studio
good morning! I’m trying to learn how to program, I started with logic + portugol. When trying to perform a condition exercise, the following error occurred in portugol studio: "There are code…
-
0
votes0
answers30
viewsas shows the exits exalta on the console
I am making a website to calculate account in the restaurant ,which is calculated in different example ways, in the account goes the items : main course, dessert, service fee, drink and snacks.…
-
0
votes0
answers64
viewsPlot in php with database values coming by loop repetition
Good morning. I need to show on the screen a bar chart that shows the value of two tests (teste1 and teste2). However, the value of test1 is saved in $valor1 and the test value in $valor2 and…
-
0
votes1
answer40
viewsQuestions about C-language loop/array
Hello! I did a basic program to calculate the averages of 4 students. The problem is that the result of it, in the final screen, appears the phrase "Insert 4 Notes student 5 here: " without having…
-
0
votes0
answers20
viewsSuccess message when registering in the oracle database but it doesn’t work: using php
I’m using the oracle bank. When I sign up for an Employee, the page displays success when registering. But when I check the bank, it doesn’t appear there. Did my code have some logic error that I…
-
0
votes1
answer80
viewsI need help understanding this code
I’m starting in python watching video lessons on youtube,the following exercise has been passed: if 10 <= saque <= 600: notas_cem = saque // 100 saque = saque % 100 I DIDN’T UNDERSTAND THESE…
-
0
votes1
answer44
viewsLoops for and while javascript
I was doing exercises to improve my logic and noticed that I can’t do decrement using the while loop? cont = 20 while(cont > 20){ cont -= 1 console.log(cont) ``` sempre me retorna undefined,…
-
0
votes0
answers45
viewsHow to Calculate Nodejs Points with mysql and sequelize of several Users
Calculo Onde puxo informções do banco || calculo acontece de forma correta pore o envio para o banco atravez do update funciona não corretamente. Basically it would pull through a loop pass through…
-
0
votes2
answers62
viewsAngular - Array calling only first item
I am trying to calculate an Array to display the total value by adding an item to my cart. My array looks like this: I use the Status to inform in the view that the item has been added to the cart.…
-
0
votes1
answer77
viewsWhat is the best way to make an if-lse?
The two examples below are equivalent, but what represents the best way to make a if-else? My goal is to display "num é igual a 0" if num is equal to 0, and "num é diferente de 0" case num has any…
-
0
votes2
answers114
viewsI’m doing a c job for college in case anyone can help
I made my code normally, but when it comes to testing it right for some and wrong for others, besides varying the answer depending on the compiler if you think the error would help a lot. #include…
-
0
votes1
answer23
viewsIdentical objects with same value fields returning different C#
Identical objects with equal fields returning different when comparing with Equals or == var oldPayments = orderNotTrack.Payments .Where(p => p.Status == Status.Activated) .Select(p => new…
-
0
votes1
answer92
viewsDoubt in Python Exercise Logic (Beginner)
Hello, I recently started my study in Python Programming Logic. I have a small base in C. I came across an exercise on the Internet where it says the following: "Make a Program for a paint shop. The…
-
0
votes1
answer29
viewsJava - Uninitialized "x" variable
I’m having a question: The code is as follows:: package yan.exercises.java.struct.repeat; import java.util.Scanner; public class exe2 { public static void main(String[] args) { Scanner scan = new…
-
-1
votes1
answer2404
viewssearch for depth and width using graphs
I need a code that does a wide and deep search using graphs for the shortest path search, analyzing these aspects mentioned, but I don’t know where to start, I would like someone to help me, serve…
-
-1
votes1
answer110
viewsProblem when displaying array
I have a problem in logic to display data from an array. Is the following: I have a function, which returns the result of entries per UF per day. In it I step 2 parameters, an array with the dates…
-
-1
votes1
answer157
viewsProblem with lottery game code
Basically the code is to simulate a lottery, the user must try to guess one of the numbers of the array, if you get it you get congratulations if it is not warned that you have made a mistake, but…
-
-1
votes2
answers101
viewsHow to detect if the typed string has more than 6 characters?
How do I detect that the string typed by the user has more than 6 characters for example??? . . . . . .. .
-
-1
votes1
answer83
viewsCalculation of relevance of a product?
Let’s say I have the following data: Video A: Procurado: 12000 vezes Clicado: 7000 vezes Video B: Procurado: 11000 vezes Clicado: 10000 vezes How can I calculate the relevance of these two videos in…
-
-1
votes1
answer1680
viewsConvert decimal to binary
I’m caught in a programming logic problem, where you need to create a Javascript function that gets any decimal and convert to binary.
-
-1
votes1
answer398
viewsUse several ternary conditions in php
How to use several ternary condition in the same line? Example: echo ($estado == 'SP' ? 'São Paulo' : ($estado == 'RJ' ? 'Rio de Janeiro') : ($estado == 'PR' ? 'Paraná') : 'teste'); That way you’re…
-
-1
votes2
answers36
viewsI am tempted to send a formlario without the ultimalization of the Ubmit input
I was wondering if it’s possible to submit a <form> as a standard text: <form method="POST" action="#"> NOME </form> When you click on the text NAME it must submit the form.…
-
-1
votes1
answer117
viewsChecking if a number is prime
I want to run a 1 to 5 and then I want to know if any of the numbers of the for is prime. for(j = 1 ; j<= 10; j++){ //Percorres os numeros a serem testados for(i = 1;i <= j; i++){ // Listo…
-
-1
votes1
answer67
viewsC# - Algorithms - For loop - Logic - Using previous value of a variable and current value of another variable
DOTNET FIDDLE Editing The following calculations correspond to actuarial calculation variables. The ages from "present age" to the age of 120 years run through the probabilities of a person’s death…
-
-1
votes1
answer273
viewsHow to calculate a value in a given range?
I have to make the following calculation: I have an input number (say 1.3), which is in my range A, which goes from 0 to 3, and I need a corresponding value in range b (which is inversely…
-
-1
votes2
answers5514
viewsHow to simplify the logical expression (~x Ʌ ~y Ʌ ~z) V (x Ʌ ~y) V (z Ʌ ~y)?
I came across the following question of logic in a leveling test that I did not know how to solve... could someone explain me the reasoning of the question? Whereas x, y and z are simple…
-
-1
votes1
answer46
viewsJavascript block loop logic
My code has an array with numerous objects, that abjects which are URL’S, with which I loop through this array and make a request for each url of the array. But I need my loop to go through the…
-
-1
votes1
answer32
viewsWhat error in my JS code (repeat loops) is not correct and is lost when the user type 31
<script> // ver porquê será que se o usuário digitar 31 ele não apresenta nada // só dá a mensagem após o 32 for ( var i = window.prompt(`digite um valor entre 0 e 30: `) ; i <= 30 ; i++) {…
-
-1
votes2
answers2149
viewsHow to detect the largest word of a string in C?
I came across this problem during a personal project, it is more curiosity really, I would like to ask anyone who can give me a light on this, because I have solved the problem in other languages…
-
-1
votes1
answer196
viewsCreate tree structure from a database query
I have a database query that results in the following table: How to turn this query into a tree structure like the one below in c#? tree = [{ text = cliente1, items = {[ text = cojunto1, items =[{…
-
-1
votes2
answers5228
viewsExample login with javascript
How do I get this login to accept 3 users? And being a valid user it directs to the index? function Login() { var done = 0; var usuario = document.getElementsByName('username')[0].value; usuario =…
-
-1
votes3
answers51
viewsIf logic with bool type and Object type
Hello, I’m cracking my head on this logic and I can’t seem to solve it; I have that code: for(let i = 0; i < mensagemDeErroDoInput.length; i++) { if(statusInput[mensagemDeErroDoInput[i].nome] ===…
-
-1
votes1
answer76
viewsHow to check more than one level of an object without the code being visually ugly?
I have an object postCardImage it is filled by a return that I have in my API, the problem is that I need to test the whole object that returned to then assign it. I take the test like this:…
-
-1
votes1
answer810
viewsSearch date and time range PHP MYSQL
Assuming there is an ex date range: 2019-02-22 and 2019-02-26 I need to search the database by date and time (I need to extract the value by specific date and time, for example only from 05:00 to…
-
-1
votes1
answer181
viewsHow to generate a Javascript Object Array dynamically
I want to "assemble" a JSON object array with data from the database, but some challenges have arisen. I have the following selection field with a method that is called every time the value is…
-
-1
votes2
answers78
viewsDoubt in vector in c
Create a counter function that works as follows: the initial value of the counter is 5. every time the function is called its counter shall be decreased. the counter shall reset automatically: when…
-
-1
votes1
answer82
viewsHow to find an ordinary sequence of Keys in an Array?
The goal is to find the next ordinary sequence of 03 Keys within a array with broken indexes, in the example would be 4,5,6 or 7,8,9 CODE <?php $myArray = array( 'item_1', 'item_2', 'item_3',…
-
-1
votes2
answers49
viewsInserting information several times
Good afternoon, I am developing a small script to organize some information that are contained in a vector, the idea is to go through two vectors, when the information of each is equal, must enter a…
-
-1
votes1
answer53
viewsFalse return on a real number entry?
TamanhoDoVetor = int(input("Tamanho do vetor ? ")) print() Vetor = [0] * TamanhoDoVetor def CriaVetor(VetorNumeros,Tamanho): for i in range(Tamanho): VetorNumeros[i] = str(input("Elemento do vetor…
-
-1
votes1
answer42
viewsGet difference in hours with specific interval
I would like to get the difference in hours between two dates with times, this is simple, however in my example should only be considered the hours of 08:00 until 16:00, this is possible? I will…