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
-
1
votes2
answers128
viewsHelp with summation
I want to write an algorithm, in JAVASCRIPT, that reads an N number and makes the sum only of even numbers var n1, n2, n3, soma; n1 = parseInt(prompt("Digite o 1º Número :")); n2 =…
-
1
votes5
answers431
viewsGo to certain link depending on the page
I’m developing a quiz with several themes, but it’s time to put it to a certain page depending on which page the person is on. I thought I’d use the if but he always goes for the last if, I’ll put…
-
1
votes2
answers322
viewsWhat does a semicolon mean after an "if"?
I was analyzing a code and came across a semicolon after a if, which means using the semicolon after a if? code: int base_calc(int cb) { if( cb < 30 ) { ; } else if( cb < 20 ) { cb = 30 - 1; }…
-
1
votes2
answers215
viewsError in php if, login authentication system
Hello, then, I’m trying to make a simple login system with php and mysql, but it’s giving error in my if. I’ve moved... too much and nothing, when it seems right it does not authenticate you put any…
-
1
votes2
answers151
viewsHelp in code printing of repeated characters
I want to print only the characters that are repeated in string and the amount of repetitions. If it appears only once, I don’t want to print it. I need help with boolena expression. How do I check…
-
1
votes2
answers48
views -
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
votes1
answer144
viewsInfinite loop with an if inside a do in Java
Good evening. I’m doing a college job on an ATM and I’m having a little doubt. I’m creating a do to make the ATM repeat menu, but before the user enters the box, it will set a value for the…
-
1
votes0
answers39
viewsWhy isn’t the instruction being executed?
I am creating a program that sorts a Matrix of structures, first sorts the rows and goes to each row and organizes it by columns. In the matrix I am using after two cycles the value of (i+1 = 4),…
-
1
votes1
answer25
viewsI cannot validate the image extension using charAt
I am trying to make a simple validation in the extension of the images that will occur the upload, but it is not working very well so far, could help me? Follow the code I’m trying to make work. var…
-
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
answer90
viewsUsing Case or if
I’m a beginner in SQL and I’m having difficulty using the CASE WHEN. I have a table called CRM_PROCESSO, in which you have a column with the option of Status, but the answer to this status is…
-
1
votes2
answers159
views -
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
votes2
answers190
viewsUsing a select value with Javascript
I need to use the value of a select in an if, at the moment I have this: Esse seria o HTML: <p>Quantidade de vidas? </p> <select> <option value="vidas1" id="vidas">Mais…
-
1
votes1
answer174
viewsHow to compare a zip code within an array with multiple ranges in PHP?
Eae personal! I’m needing a hint on how to filter a zip code into a list that will have multiple ranges, if (IF) the zip code is inside that list, run an HTML that has some strings in PHP. Basically…
-
1
votes2
answers117
viewsWhy do you enter if even if it is false?
Even though the condition is false, he enters the if, always assigning the last position in both cases. However, when assigning the for in the variable index notas, works properly. For this code to…
-
1
votes1
answer44
viewsWhy can’t "If" verify equality between Ctype(double, int32) with int32?
I have a function that returns me a Double and need to check if the result is equal to 5000. I am using If CType(resultadoFunção as double, Int32) = 5000 Then, but though he shows 5000, he does not…
-
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
votes1
answer83
viewsNumerical comparator
print ("Insira dois valores para serem comparados:") Valor1= float(input("Escreva um número:")) Valor2= float(input("Escreva outro número:")) print ("Os números que você inseriu foram esses?","\n",…
-
1
votes1
answer53
viewsR - How to generalize a function if data is missing.frame
I created the function below to calculate the descriptive statistics of certain companies separated between the 5 regions of Brazil and the total and present in a table. library(tidyverse)…
-
1
votes2
answers120
viewsMysql - Select - how to group two different values into a single value
I would like help on a subject. I have a query that lists requests(orders), and each request has its status, for example: 'confirmed', 'refused' and 'unmarked', I would like to create a Select that…
-
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"…
-
1
votes1
answer25
viewsHow to exclude the answer from an if if the input applies to another if?
For example, I was studying and I came across the following problem: If I do a little program to tell me if a number is multiple of 2 and 3, they will have numbers that will be multiple of both. The…
-
1
votes1
answer56
viewsHow to reduce the size of this function that contains multiple if?
I wanted to think of a logic that would decrease the size of this code, because it ends up repeating itself. It is an experience calculator for a game. You set your current level and the level you…
-
1
votes1
answer64
viewsif - Else if condition being ignored by browser
Guys I have the following if - Else if condition for file upload check, depending on the file it allocates at a position of the array, however when arriving the name to do the validation it ignores…
-
0
votes1
answer873
viewsPlace an IF with various conditions
I want to put an If with various conditions. if ($row[??] != '' or NULL or 0000-00-00 ) Currently I have like this but I want to put two more Row. I have to create more if or I can add in that If?…
-
0
votes1
answer593
viewsPHP: Function as a condition for an if
I would like to know if it is possible to use a function as a condition for a if. Example: function estaParaExpirar($data, $dias) { return(strtotime($data) < strtotime("+".$dias."days") ); } if…
-
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
votes1
answer733
viewsComparing dates of an array in PHP
I’m trying to compare the dates that come from a database array to be able to organize them within a timeline. The problem is that I can’t compare the dates to know where to place each entry...…
-
0
votes1
answer145
viewsInitial condition (IF) does not work
I’m trying to make an old game. So far I managed to make the appointments change every turn and the function to delete the appointments. ps: I’m using black and red color instead of ball and "x". My…
-
0
votes1
answer34
viewsConditional Tags Worpress for mobile devices
How do I use a Conditional Tag in my wordpress theme so that a certain script is not loaded on mobile devices. There is such a tag? If there could show me an example? In this example the script…
-
0
votes2
answers2017
viewsCheck if $_GET exists within the view
Guys is the following, I have a standard html file, which contains : <header data-color="<?php echo $client->client_color; ?>"> <h1> <?php if($client->client_image != ''):…
-
0
votes2
answers4855
viewsHow Select SUM(',''',''''')
Personal I’m just with a doubt, about how the mysql select works. Select SUM(IF('','','')) I’m using it but I don’t really know how it works
-
0
votes1
answer4352
viewsDoubt how to use IF in a TRIGGER in mysql
Hello! My problem is the following I have two tables, a table called notes and another call students. I need to make a comparison with the id_student on the table notes and the id present in the…
-
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
answers73
viewsLogic optimization
I have the following logic that I need to optimize using PHP Parâmetros: máximo mínimo alerta Se ultrapassar o nível máximo enviar um alerta Se alerta já tiver sido enviado não enviar nada Se o…
-
0
votes1
answer6172
views"No such file or directory " error but the file is saved in the database
I have the following problem: when I submit a form containing photographs the error described in the title appears. If you only upload a photo, it will no longer appear. But even if you make a…
-
0
votes0
answers13
viewsDifference between If instruction and If operator
What are the differences between the if instruction and the if operator in VB.NET? If(Condicao, x(), y()) If Condicao Then x() Else y() End If…
-
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…
-
0
votes1
answer83
viewsArray ? How to resolve
There is this site that I am setting up where I made a junction of a code that insert watermark with a form where it would be possible to choose which brand would be superimposed on the image that…
-
0
votes1
answer44
viewsInsert an "IF" with "DO" to validate _POST field
Gentlemen, can someone help me with the code below? I need to put an IF before the DO. I need to validate a _POST variable [so_server}. If it is Linux after DO would put a form structure, ELSE put…
-
0
votes1
answer742
viewsIF inside while PHP/MYSQL
I’m listing some results within while my goal is that when any of the variables I list in while come empty, it lists only those that come with content. ps. is a polling system, I put to register 4…
-
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
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
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
answers941
viewshow to get bank value in an if using php
people i have a table user who has a category field that is a field Boolean, at a certain point in my code I need that only if category is true I show an option in my menu, but do not know how to…
-
0
votes1
answer418
viewsCount the amount of my IF records
IF(Count(UCID)>1,Count(UCID),'0'), it brings me approximately 500 lines of record, being numbers of 2 above, I want to be able to make a COUNT in that IF to present those 500 in a column to part.…