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
-
2
votes2
answers196
viewsCode to generate random number sequence does not work
I developed a C code to generate a sequence of random numbers to be typed by the user, but it’s the first time I make a source code of the type for a college job, and according to the research I did…
-
2
votes1
answer177
viewsHow to make a #if with comparison of two variables using handlebars and nodejs
My problem is in creating #if with a comparison with two variables on the .handlebars. page In the edition page I retrieve the data and fill in the fields, however in my select, I need to compare…
-
2
votes3
answers279
viewsIs there any way to replace these ifs?
if(inputUsuario >= 16.15 && inputUsuario < 16.20){ inputUsuario = 16.20; } if(inputUsuario >= 16.00 && inputUsuario < 16.15){ inputUsuario = 16.15; } if(inputUsuario…
-
2
votes1
answer53
viewsProblems when grouping information through ifelse and case_when functions
I am trying to group the information contained in each of the Brazilian states into regions. Initially I checked the distribution of these in each state through the function table. Dice:…
-
1
votes2
answers1507
viewsHow to display multiple error messages simultaneously in form?
I’m trying to get my log page to show all forgotten fields messages together as in this example: But it only shows in parts: 1 - "Username already exists" and "Email already exists" or 2 - "Please…
-
1
votes1
answer1128
viewsPerformance: Switch or if aligned?
Independent of language, the switch has better performance than an alignment of ifs? If yes: why? if ... elif ... elif ... else ... end switch case ... case ... case ... else ... end…
-
1
votes1
answer280
viewsC++ if select object
I am making a program for Rduino written in C++ to turn on and off leds when a button is pressed. I created an Led class and put in it the methods, now I wrote an if that checks when a button is…
-
1
votes1
answer375
viewsHelp: Valuing a char vector of a struct within an if
I’m trying to define the value of a char vector of a struct within an if, but without success... The struct itself: struct ficha { char nome[31], classificacao[31], telefone[21]; float altura, peso,…
-
1
votes2
answers327
viewsIf condition in variable
I have a variable called Lastclass, it can have the value of headerSortDown or headerSortUp. I’m rescuing her from an orderly column. I want to transfer this variable to a <a href> but wanted…
-
1
votes1
answer280
viewsHow to return a Boolean on the button
I have a button and I want when it’s clicked to return true in a if of another class, but I haven’t found any method of how I do it. Button b = new Button(); Other class: public static…
-
1
votes1
answer122
viewsIF in Reply function POST does not work
have a POST inside a javascript function and this post returns a response function the problem and that the IF in the response function is not working <script> $(document).ready(function(){…
-
1
votes2
answers520
viewsProblems with if and conditions
I’m making a code that receives three values and orders them from the highest to the lowest. As a condition, when the numbers are repeated, an error message is displayed and the program must close.…
-
1
votes3
answers1212
viewsPHP - Comparing information
I’m trying to compare the number inserted in the textbox with a number defined in the variable, like this: <?php $campo1 = $_POST['um']; $valor1 = 1; if($campo1 == $valor1){ $msg="ok"; } else{…
-
1
votes3
answers149
viewsHow to delete a DIV if there is a word in another DIV in jQuery?
I’m trying to make the following condition: $(document).ready(function() { if($("#content .productName").html().indexOf("JBL","Oversound")==-1) { $("#pague-so").hide();} }); In this case, I want the…
-
1
votes2
answers161
viewsHow can I use something like an IF in an SQL query
I am applying a query SQL in the Oracle SQL Developer in multiple tables where a Column a view is null in some places and then I will need to use values from another Column and I don’t know how to…
-
1
votes0
answers97
viewsPHP/Bootstrap - Replay up to X and then up to Y then includes new DIV and continues replay
I’m breaking my head in this repetition, as this is my first question, sorry for the mistakes. :) Currently I have this block of codes inside the container: <?php echo '<div class="row">';…
-
1
votes1
answer494
views -
1
votes1
answer1838
viewsError typing IF and Else in jquery
I’m starting to venture now into the world of development and hit a question while using IF and Else. The code below is OK <select id="course_list" > <?php $my_query = new…
-
1
votes2
answers2638
viewsHow to call a method into an If and Else?
I am developing software for a video rental company with Pattern MVC (Model-view-controller) design and the problem of not calling the save() method and the change() method is occurring inside If…
-
1
votes1
answer124
viewsIF condition in javascript only works once
I’m trying to make a Side Navigation, so in Internet search, I found a little tutorial on the site: How TO - Side Navigation However, in my example I wanted a single button to open and close, so I…
-
1
votes2
answers325
viewsHow to test the factorial in Main()?
How would the main() of this function below? The user enters a number and appears on the screen the factorial of the same. int fatorial(int num) { if (num >= 0) { int fat = 1; while (num > 0)…
-
1
votes1
answer284
viewsIn this case use switch or if?
I have an exercise to do which consists of the following: The user informs the salary, and depending on the amount informed, he earns an increase according to the table. Example: From 1000 to 1500…
-
1
votes1
answer1393
viewsDifference between if and elsif
I know these two terms don’t exist in the same language (correct me if I’m wrong), but in some languages (C#, in the example below), we have the following code: if(condicao){ ... } else if…
-
1
votes2
answers325
viewsMatch more than one condition in a junior
Is it possible to combine more than one condition in the first one? Example: boolean existe = pessoa tem 23 ou pessoa tem 22 ? true : false ; I’m trying but I can’t.…
-
1
votes1
answer607
viewsTo select a switch/case statement each click on the button
I would like to make list(Gem) of A-Z. A detail, based on breaking/dividing this list(Gem) alphabet into parts: Although my difficulty is in, after being clicked on the button, the same bring up the…
-
1
votes1
answer197
viewsHow to work with if and Else?
Good morning. I would like to get help from you to build this code because I am not able to implement it. $query1 = "INSERT INTO paciente VALUES ('NULL, $nome_paciente, $nome_doutor')"; $id_paciente…
-
1
votes2
answers180
viewsHow to ignore sentence and case in Java . startsWith
This is my code: if(e.getMessage().startsWith("/reciclar") || e.getMessage().startsWith("/ereciclar")){ e.setCancelled(true); p.sendMessage("§cComando Bloqueado/Em Manutenção!"); } But if you use…
-
1
votes1
answer88
viewsJavascript conditions not working
I am making a calculation with the following information: Style, experience, height and weight. With height and weight, I take the user’s BMI and compare it to their experience. With style, I define…
-
1
votes1
answer117
viewsdoubts with if Else in java script
I’m using Angularjs and I have this method $scope.login = function (email, usuario, senha) { $http.post("/Login/login", { email: email, usuario: usuario, senha: senha }) .success(function (data) {…
-
1
votes0
answers83
viewsBlock entries beyond the value stipulated in PHP form
I have a course administration system where the teacher registers a class and the student accesses a page with a table with all classes and enrolls in what he thinks best. The problem is that many…
-
1
votes2
answers765
viewsWhat does if(variavél){ /*action*/}mean?
When placing only to variable within the if, for example if( variavél ){ /*ação*/} What does that mean if? And to the contrary if( !variavél ){ /*ação*/}…
-
1
votes1
answer69
viewsCondition Else being called at the wrong time
I’m currently having problems with a work code. My ELSE class is always running, but only when I choose the option for the first IF. import java.util.Scanner; public class BikeFit2 { public static…
-
1
votes2
answers1892
viewsIF, ELIF AND ELSE
I’m taking my first steps in Python, and I came up with a question in the if/Else sentence, trying to solve the following exercise: "Using a person’s height and gender as input data, construct an…
-
1
votes1
answer52
viewsProblem with $_POST and IF
I am trying to do q if the person type 12 in any part of the text he enters the if but he is not entering if ($_POST['mensagem'] !="%12%"){ echo"vc digitou 12"; }…
-
1
votes2
answers2342
views -
1
votes1
answer461
viewsHow to make condition receive a parameter followed by an argument
I’ve been trying to create a structure if..else with a parameter passing. See: Example $ opt-get -i pacote.tgz Yes, I’m creating something similar to tool apt-get of the Operating System Debian. I…
-
1
votes1
answer39
viewsSyntax error: Variable problem inside the IF
My code: DELIMITER // CREATE FUNCTION f_desc (in_preco int) RETURNS INT BEGIN DECLARE fim_preco INT; IF in_preco >= 100 THEN -- aqui fim_preco := format(10 * in_preco/100, 2); ELSEIF in_preco…
-
1
votes1
answer40
viewsHow will this if be interpreted?
I have a function that performs different actions on the page according to the callback passed to her, I am using if to verify which callback called on function('callback') but now I needed to do an…
-
1
votes1
answer149
viewsPHP for each with an if rule
I have a table that brings paid and unpaid commission results. I want him to bring only the pay, I mean, if number_format($row->amount_paid,2) = 0 not bring that line. <?php $i=-1;…
-
1
votes1
answer218
viewsWhy aren’t you entering this if/Else?
I run this code and the if/else if are not entering. What can be? import java.util.Scanner; public class VerificaLetra { public static void main(String[] args) { String sexo = " "; String letra;…
-
1
votes0
answers118
viewsHow to reduce the instruction block inserted within a conditional if structure in python?
Hi, I’m developing a program that calculates and sizes wall beams. It works basically with security checks (request less or equal to resistance), when one of these checks is not met, the program…
-
1
votes1
answer185
viewsLogical doubt of PHP code
Hello, folks. I’m starting in PHP and am having some problems with this code: <?php function linha($semana) { echo "<tr>"; for ($i= 0; $i <= 6; $i++) { if (isset($semana[$i])) { echo…
-
1
votes3
answers181
viewsDifference between two codes
Code 1, if variable num is 1 or 2, for example when the conv() is called again and I choose option 3 to exit then wheel the print I hope I have been helpful (: but the program does not close, only…
-
1
votes1
answer3593
viewsHow to compare a string of an array in C?
I have the following variables : char nome[10][8]; int i; --> Sendo esta para o loop I ask the user to enter 5 names and then I read the variable : printf("Entre 5 nomes : \n"); for(i=0; i< 5…
-
1
votes1
answer190
viewsHow to put a variable alert in the onclick parameter of a link? using jquery and php
I need to put an unavailable product message on my system, which takes the available status of db (YES or NO) I made an IF that changes the image of the product when the status is NOT but I want a…
-
1
votes1
answer100
views -
1
votes1
answer236
viewsPython Error in if
I am having an error in the if and do not know how to correct this error, I am using Python 3.6 and Pandas for reading, writing and data analysis. df1 = pd.read_csv("JonnyTheBoy10.csv",…
-
1
votes2
answers123
viewsCondition "if" does not enter
Why does this type of condition not work in Javascript? if (permissoes[0] || permissoes[5] || permissoes[10] || permissoes[15] || permissoes[20] || permissoes[25] || permissoes[30] || permissoes[35]…
-
1
votes2
answers108
viewsIf you are not checking the condition correctly
I was trying to make a very basic little program to know if a variable had a second decimal place or not. However I came across a "bug", which in my view is bizarre. Code: #include <stdio.h>…
-
1
votes1
answer240
viewsIf within PHP Field
Good Afternoon, How to Make an if within variable value assignment. $html =' <body> <table width="100%" style="background:#00aeef;"> <tr><td> <table width="596" border="0"…