Most voted "if" questions
The "if" statement is a control structure in many programming languages that alters the execution flow depending on a binary condition - also known as Boolean logic. This tag should be used when the question is related to the use and/or performance of the "if".
Learn more…467 questions
Sort by count of
-
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
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
answer23
viewsIf it’s not working properly
Hello, guys. All right? So I’d like to ask you a question. I created the following code: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner entrada = new…
-
0
votes0
answers24
viewsJavascript: Change background and show selections in TEXTAREA resulting in error 405
Hello! This is the following exercise: Click on the go button: Change the background color Show selection of newspapers in the textarea When I click on the button, the page results in error 405. I…
-
0
votes1
answer44
viewsDoubts about if clause
I have a problem in the query below: THERE ARE SOME DATA THAT ARE ON D1_NFORI, THAT MISSING "0" THE LEFT WOULD NEED TO INCLUDE THE ZEROS TO COMPARE IN THE WHERE EXAMPLE: Where IF D1_NFORI NOT LIKE…
-
0
votes1
answer49
views -
0
votes1
answer143
viewsVector comparison program C++
You guys all right? I’m beginner and I’m trying to build a program that compares two vectors and if all the elements of the two vectors are. I’ll exemplify it to get better... vector 1 = 10, 20 , 30…
-
0
votes1
answer93
viewsUse if with matrices
The question ends up being logically easy, but I’m having difficulty knowing how to use the if condition in the values of the matrix, I don’t know how to do to mess with the values of the matrix. my…
-
0
votes2
answers41
viewsphp if does not work when you have nothing declared by url
I have this error in the variable put to show the code only when you have the reference. but the error when you have nothing declared. That is, when accessing the site with site.com/? ref=app…
-
0
votes1
answer20
viewsTaking data from a select to trigger an IF before sending the data (POST)
I am improving my original project, where the Giovane solved the problem I had, but now I’m in a situation where, depending on the select, I’ll have different options and actions. In my current use,…
-
0
votes1
answer58
viewsDoubt if/Else (Javascript)
I’m starting to study programming and JavaScript I had an obstacle with the if/else. In the code, the if always performs, but the else no, I’ve made several modifications (including adding the…
-
0
votes1
answer75
viewsIf/Else block not working in Javascript
I’m starting in Javascript and I’m creating a Whatsapp bot on Node.js and any block if that I put does not work and always goes to else. It works that way: Get the message; Query the Sqlite database…
-
0
votes0
answers36
viewsValidation of strings in C
Good afternoon, I am learning C in college, and the following challenge has been proposed: A seller needs an algorithm that calculates the total price due for a customer. The algorithm must receive…
-
0
votes1
answer30
viewshow to include letters in my list in python and inform the user that it has been repeated
for letra in palavra_secreta: #print(inclui_Letras) if (chute == letra): letras_acertadas[index] = letra inclui_Letras.append(letra) # incluir o 'chute' na list 'inclui_letras print(palavra_secreta,…
-
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
votes1
answer50
viewsIs there any function in R, whose return is identical to the return of excel’s SEERRO() function?
I am trying to generate a general function, which runs several regression models. The problem is that when a model gives error, the main function stops. I would like to use a parole that in case of…
-
0
votes1
answer48
viewsDoubt regarding the existence of an "if" in the code
Question statement: Construct a function that will receive two Strings of varying sizes and will return True or False if all characters (regardless of whether they are upper or lower case) are…
-
0
votes0
answers17
viewsConditional - If, Elif, Else
I am a beginner in Python and I have the following script running by Vscode and Pycharm terminal. from math import pi import sys def help(): print("É necessário informar o valor do Raio.")…
-
0
votes2
answers55
viewsMake an If in c++ by limiting the answers
The user types the year, month, day and temperature, but I need to limit the answers. ano may not be less than 1850 and greater than 2021 mes may not be less than 1 and greater than 12, dia may not…
-
0
votes0
answers16
viewsDoubt about if, Elif and Else
Good morning/late/evening I started to venture into the recent python and was making a code for a simple calculator exercise. print('Calculadora simples') def calculadora(): x1 = int(input('Digite o…
-
-1
votes1
answer67
viewsThe code does not respect ifs
Hello, in this code when it runs it does not respect ifs, it goes straight through running everything. For example, if the message "This user does not exist" appears it should simply end. but also…
-
-1
votes1
answer409
viewsIf Else if in Javascript
I’m developing an application using phonegap/Cordova that stores data using localStorage and I’m having a problem with javascript... I’m calling a function to save() my data, a function to load()…
-
-1
votes1
answer381
views -
-1
votes2
answers381
viewsHow to create several variables of the same type without repeating conditions?
import java.util.ArrayList; import java.util.Scanner; class Main { public static void main(String[] args) { Categoria c1 = new Categoria(); c1.categoria = "-Reprodução"; c1.nome = "Ahmed Shafik";…
-
-1
votes5
answers2297
viewsStore IF output in a variable to use later
This code is in error when I call the variable $os: $os = (if($status_os_cliente == "A"){ echo "SIM"; } else{ echo "NÃO"; });
-
-1
votes2
answers62
viewsDoubt with select in if
Good afternoon I was trying to adapt a code I already had here so I could put a watermark on a photo. But it’s been a long time since I’ve done html or php. So, you could give me this help to fix…
-
-1
votes2
answers417
viewswhat I must do to authenticate the user correctly
I’m in need of help to authenticate users on my site but I don’t know what the sql variable that I hosted returns when you find the right user what I put in if? <?php include 'conexao.php';…
-
-1
votes1
answer101
viewsWhy does the IDE indicate that a code in the "if" will not be executed?
Observe the code: Because the development IDE is not considering line 34, 35 and 36 code? You weren’t supposed to be on probation?…
-
-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
answer32
viewsScan 4 selects and display message
Speak up, people, blz? I would like to know how to make the following logic in SQL: if( 1 = select * from tblA or 1 = select * from tblB or 1 = select * from tblC or 1 = select * from tblD or )…
-
-1
votes2
answers166
viewsQuery return comparison with "N" status
I need help for comparison in "if" c# of a datatable database return. Below the code snippet: public class ArcerarDto { public DataTable SelectArcerarContract() { ArcerarDal arcerarObj = new…
-
-1
votes1
answer143
viewsCan I use many IF’s in PHP?
I’m doing a project where I need to create a csv from a mysql table, to create the csv I need to follow the norms of type documents, when I went to write the code I realized that it would possess…
-
-1
votes3
answers1163
viewsError using Else: "'Else' without a Previous 'if'"
I’m trying to make a basic program, but I stopped in half because it was wrong: error:'Else' without a Previous 'if' #include<stdio.h> int main() { int med1, med2, med3; printf("\nDigite a…
-
-1
votes2
answers103
viewsCode always falls on the same if
Why the method souVelho() only returns the answer "You’re new." regardless of the typed age? What’s going wrong? public class Pessoa{ private int idade; public Pessoa(int idadeInicial) {…
-
-1
votes1
answer499
views -
-1
votes1
answer35
viewsIf as function
How to define an "IF" run according to text of a "var"? Ex: var Ativar = { ativo: 'sim' }; I intend to use the "yes" for "IF" to validate and execute. Does anyone know how to? Pardon my explanation.…
-
-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
answer55
viewsI need help with this code
Personal I wrote the following simple code in my python: nome = str(input("Qual o seu nome?")) if nome == 'denise': print("Nome bonito") elif nome == 'maria' or nome == 'pedro' or nome =='joao':…
-
-1
votes1
answer74
viewsIf only returns the first result
Hello, I’m having the problem in the code where my "IF" only returns the first result: if ($aluno['janimal']="1"){ $animal = "Réptil";} elseif($aluno['janimal']="2"){ $animal ="Cavalo";}…
-
-1
votes3
answers81
viewsHelp with code reduction in If/Else
I am trying to clean the body class without having to put this amount of code in if/Else function bgColor(event) { evento = event.target if (evento.classList.value == 'vermelho') {…
-
-1
votes1
answer62
viewsError of expression "if"
My code is giving this error in the first expression se: "The expression was not started correctly. Enter the character '(' to fix the problem" real m1, m2, m3 escreva("\n Digite o peso da primeira…
-
-1
votes1
answer38
viewsCannot use isset() in the output of a PHP expression
I want when my site is accessed with the reference? ref=app show a page, if it is not going to appear another. But just make that mistake: Fatal error: Cannot use isset() on the result of an…
-
-1
votes1
answer20
viewsHow to make a URL that updates every second without updating my page
Well I have a code in php, with an if and I would like if I could get the answer from Curl, only q this answer it updates every second so it is almost impossible if I get the answer like this, there…
-
-1
votes0
answers48
viewsI have a problem with "if" (Python3)
Well, I was doing a Statistics program (don’t notice the way I wrote I’m new to programming and I was trying to do it using everything I learned from just an introductory course with little…
-
-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
votes3
answers299
viewsHow to make Visual Studio interpret an hour that is larger than 23hrs and smaller than 6hrs at the same time?
I have a function that is called and must enter the condition where the time now is greater than 23 hours and less than 6 hours at the same time, however the code conflicts with this condition and…
-
-1
votes3
answers2084
views -
-1
votes1
answer90
viewsProblem with if in Java
I’m trying to make a program like "lottery", locked in a mistake there on if. If you can help me, follow the code: package praticando; import java.util.Random; import java.util.Scanner; public class…
-
-1
votes1
answer22
viewsCompare 4 Variables and execute unique code for each result
Hello, I’m trying to create a comparison where the next action will be different for each variable value someone can help me. The intention is if the value is true, executes one function if it is…
-
-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…