Most voted "else" questions
104 questions
Sort by count of
-
36
votes4
answers58476
viewsIF, ELSE IF, ELSE or IF IF IF. When to use, what’s the difference?
It’s a very basic question, but it intrigues me a lot. See the code below: var bola = "redonda"; if(bola == "comestivel") return comer(); if(bola == "liquida") return beber(); if(bola == "redonda")…
-
27
votes4
answers3196
viewsWhat is good practice when casting an exception within if?
What is the best practice in this case, use the Else even knowing that the if will or will not make an exception? option 1 (with Else): if (condicao){ throw new RuntimeException("Mensagem"); }else{…
-
9
votes3
answers2573
viewsIs it possible to avoid using ifs in these cases?
I have read many materials on the internet about OOP, the overwhelming majority says to avoid if/else at all costs. For an OOP beginner like myself, many doubts arise. For example: if…
-
9
votes2
answers1709
viewsThere is an "Else while"
Is there any way I can do that? As long as it’s one thing to do that, then when it’s another to do that? For example: var i = 0; while(i < 5){ //faça isso i++; } else { //faça aquilo } It’s…
-
9
votes3
answers318
viewsIndentation in statement "Else"
What is the difference in the indentation of else "out of" the if. In this case it is to return the prime numbers up to the nth 'n' value. First case: for i in range(2, n): for j in range(2, i): if…
-
7
votes3
answers187
viewsOmitting Else is a good idea in some cases, right?
I ask myself this question every time I’m coding, because I always worry about leaving my code understandable to other programmers who will contemplate it - and myself, because maybe I won’t…
-
5
votes2
answers3228
viewsQuestion and answer with if and Else in Java
No matter what I say, both "yes" and "yes" just show the ELSE. Where am I going wrong? package saudacao; import java.util.*; public class Saudacao { public static void main(String[] args) {…
-
5
votes3
answers24766
viewsIs it possible to use if Else in Mysql queries?
I’ve been searching the internet and hearing rumors that it is possible to use if else in Mysql queries but saw nothing concrete about it. Is it even possible? If so, how? I want to make a query in…
-
5
votes0
answers48
viewsUse of Else outside an if
I was writing a program that would give me all prime numbers between 1 and a certain number that should be informed by the user. After several adjustments to the code, I came to the following final…
-
5
votes2
answers1797
viewsIs there any way to decrease the amount of Else and if?
I should create the conditions for enrolling students based on their age, I was wondering if there is any way to decrease the amount of if in that part of the code: int idade =…
-
3
votes2
answers70
viewsPHP parametric functions
I am new in php and I am creating a comparison of box sizes, and for that I would like to put inside a function more I do not know which parameter to put inside the relatives of the function.…
-
3
votes5
answers631
viewsIf Else with functions
It is possible to use a if-else with function "Function();" example: if (a > 1){function Save();} else {function NoSave();} I just need to know if functions are loaded into the head work within…
-
3
votes1
answer91
viewsJavascript toggle or if/Else on Adobe Edge Animate
I use Adobe Edge Animate for simple animations at work. I couldn’t get one of them to work and I did a trick. Now I want to know how to do it right. I have a button. When clicked, it should play on…
-
3
votes1
answer1756
viewsError: The condition has length > 1 and only the first element will be used
I am writing a code in the R but it informs the following error: In if ((Bwgmax * (1 - Exp(-K * (Mcisimulate - Xm)))) > WG) { : the condition has length > 1 and only the first element will be…
-
3
votes2
answers2069
viewsDisplay the highest and lowest value between two integers when they are different from each other
I am not able to display the values of smaller and larger. Make an algorithm that reads two numbers and indicates whether they are equal or, if different, shows the largest and smallest in this…
-
3
votes1
answer65
viewsproblem with Random.radint(1, 6) and if conditional
Friends, I am starting out in programming, so I apologize if it is too banal my question. My guess is that something happens in the if string, because never the winning message is read, the program…
-
3
votes4
answers1152
viewsJavascript function with Nan error
Hello. I am encountering a problem when executing this formula as the final answer is given as Nan. In a simplified way to explain the code, it works like this: there are two groups of three…
-
3
votes2
answers175
viewsDoubt of if He is
Good evening, I was testing this C code of an activity* of my course, works ok if (c<101||c>103), works ok if if (c=101), but if (c=102) if instead of returning me ns=s+(s*0.2), is returning…
-
2
votes1
answer530
viewsAlternative to If/Else
I have the following code: private void maskedTextBoxEAN_Leave(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(maskedTextBoxEAN.Text)) if…
-
2
votes2
answers484
viewsHow to use multiple answers for the same variable in just one if?
It is possible to use only one if for several possible values of the same variable? For example: Instead of writing: var nome="" var nome=prompt("Digite seu nome"); if (nome === null){ alert(Você…
-
2
votes1
answer341
viewsElse does not work in PHP
I’m trying to use the code below, but the else does not work. Returns error Parse error: syntax error, unexpected 'else' (T_ELSE) <?php if ($status == 'True') ?> <div class="col-lg-3…
-
2
votes4
answers82
viewsHow do I create a list for possible answers in python?
Well... I wanted to make a list for possible user responses to input, for example: nom = str(input('Você gosta de mim? ')) lista = ['sim','claro','obvio'] if nom == lista: print('obrigado, bom…
-
2
votes2
answers95
viewsDoubts with the use of IF / ELSE in C
When I run this code and type sex=M or =F, all conditions are executed as expected. When I type sex=m or =f, only the first condition is met, regardless of the age value. Can anyone explain me right…
-
2
votes5
answers192
viewsCode executes a line that should be conditional
I am doing a job for college at C++ and, when performing an if/Else for a value of totalf equal to or different from 0, it is not obeyed. How do I exit display only a certain printf of correct…
-
2
votes3
answers653
viewsWhen to use if or Else If?
It’s a pretty silly thing, but during my writing I came across the following question: When is it really necessary to use if's or else if's in my code? Is there any impact on performance? I will put…
-
2
votes1
answer125
viewsI need help on the if and Else structure
I created two 'if and Else' structures to make the program write to the user using the plural correctly and as you can see below, I created two variables within the structures to assign the plural…
-
2
votes3
answers307
viewsHow to use if, Elif and Else
GOTHAM CITY Challenge (level 1) You are a police officer and need to report a criminal activity and on report you will give a number from 0 to 10 regarding the level of the crime. Make a code that…
-
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
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
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
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
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
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
votes2
answers78
viewsDoubt if Else returning 0
I’m trying to do the following exercise: 10)A fruit plant is selling fruit with the following price list: Até 5 Kg Acima de 5 Kg Morango R$ 2,50 por Kg R$ 2,20 por Kg Maçã R$ 1,80 por Kg R$ 1,50 por…
-
1
votes1
answer575
viewsHow to use "if-Else" sets correctly in C?
I have a problem with this code in Devc++, because in my view the conditions part if-else is perfectly indented and organized (all if possesses its else and your keys). The error is in the last…
-
1
votes2
answers121
views -
1
votes1
answer110
viewsConditional structure (if Else) javascript
I am studying Javascript and I have the following problem: <!DOCTYPE html> <html lang="pr-BR"> <head> <meta charset="UTF-8"> <meta name="viewport"…
-
0
votes2
answers3050
viewsIs it possible to have a ternary without the Else block?
There is the possibility of creating a simpler if ternary, I say without the code of the Else block? how would it look? guy : if($total < 10){ $total_gerente = 10; } Because from what I know the…
-
0
votes2
answers895
viewsError in using Else
The program is giving an error when compiling. Else without a Previous if Something about the else, there’s something wrong with the condition if and else? #include <stdio.h> #include…
-
0
votes4
answers1051
viewsHow to do if and Else of between 2 variables with output in a third?
I’m so sorry, but I had to rewrite my entire question because I wasn’t being objective enough to make myself understood, when I omit code as was the previous case is not to hide something is just to…
-
0
votes2
answers452
viewsHow to make an if/Else within a route?
I have a form that has two types of users: administrators and developers and each one has its post login page, but even logged in as an administrator, I can go to the developer pages. I need to fix…
-
0
votes2
answers80
viewsStopped running when I added the printf
I made a source code in C, conditional, but when I add a printf function windows reports that the program stopped running. Look at the code: 1: http://i.stack.Imgur.com/a9YUf.png NOTE: I USE WINDOWS…
-
0
votes2
answers70
viewsPicker View - Display an Imageview according to the sum of values
Hello. I’m trying to work with Picker View to display a combination of values. var pickerDataSource = [["a", "b", "c", "d"],["1","2","3","4"]]; Doubt is; how are results within a condition? if(row…
-
0
votes1
answer34
viewsHow to condition email sending content with a chosen variable in the form?
I am trying to condition the email sending format by to a certain option chosen by the user, in the Subject / Script : If the option is SCRIPT, the contents of the $html variable will be sent. If it…
-
0
votes1
answer201
viewsCorrect use of "goto" with "if Else"
I have a question about the correct use of the "goto", I made a small example that illustrates my doubt: <?php $valor01=10; $valor02=8; if($valor01 > $valor02) { echo "valor01 é maior que…
-
0
votes2
answers148
views(if/if) with check box
I have the following problem: I have a decision structure that checks the check box. However, when I select the two boxes, the code still executes the commands that checks if only one of the boxes…