Most voted "switch" questions
In programming, a switch instruction is a type of selection control mechanism used to allow the value of a variable or expression to change the program execution control flow
Learn more…134 questions
Sort by count of
-
2
votes1
answer324
views -
2
votes4
answers801
viewsHow to use switch in C?
I have to understand this code that my advisor gave me. The opt after switch is mandatory? The command break too? Why doesn’t it appear after the options case '?' and default? if( argc <= 1) {…
-
2
votes1
answer54
viewsOutput condition on do-while in code C
I need the user to enter the numbers 1, 2 or 3 to choose the locations, and if not select one, ask again. But when entering the number 0 or 4, for example, it returns to the start screen (that would…
-
2
votes1
answer145
viewsSwitch entering wrong case
I’m trying to solve the Uri 1038 problem using switch, apparently the values are merging, Item 3 for example, multiplying by 2 (5 x 2) returns the value 3. What I’m doing wrong here? #include…
-
2
votes0
answers248
viewsSwitch Case - Break and Return inside a Function - Arduino
Hello, good afternoon! I would like to understand how the switch case works in the Arduino C++ language. I have the following hypothetical situation: estado_principal=0; estados_Japão=0; setup () {…
-
1
votes1
answer4080
viewsHow to make a switch in Ruby?
How can I make a switch in Ruby?
-
1
votes2
answers298
viewsError with $_GET function
Personal my question is the following, I have the page criareditarevento.php that updates information from a registration system, but I need to make the update message open inside the page main.php…
-
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
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
answer90
viewsProblem with switch C
I have a C code, and without the switch, it works right, but with switch, when entering name in the list, replace all the name of the list by the same. void insChild(LIST* l, char name[]) { NO* new;…
-
1
votes1
answer399
views -
1
votes1
answer132
viewsswitch case to work when migrating from PHP 5.6 to 7.0
I have a news system running with PHP 5.3 and would like to upgrade it to at least 5.6. I have been using Php_codesniffer-master and Phpcompatibility-master to assist me in the change. Most of the…
-
1
votes1
answer110
viewsHow to check if something has been passed to the php page?
It is even difficult to ask because I do not know if this is right, but I will try to explain it in the best way possible. I have a page where I will use the php case switch to decide the action…
-
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
votes2
answers3887
viewsHow to use a switch inside a switch?
In case, I can not choose the option of the menu select difficulty, I am doing the switch correctly inside a switch? #include <stdio.h> #include <stdlib.h> #define TENTF 5 #define TENTD…
-
1
votes1
answer914
viewsProblem calling class inside Switch
I’m developing a facul project that’s a basic clinical system. After the user logs in, they choose an option in the menu where the responsible class will be called. The problem that when I choose…
-
1
votes3
answers600
viewsCreation of Array within Function
I’m trying to do an exercise where I have to create a array within a function, and the same be accessed through an external code (example: ...php? parents=uk and show United Kingdom - London). The…
-
1
votes2
answers63
viewsProblems with the switch
I am facing problems with this code, when running it the default runs also and in no time I entered with some data other than in the cases. // faz loop até usuário digitar a sequência de teclas de…
-
1
votes1
answer115
viewsBuild error: expected ';' before 'case'
I’m trying to compile this program here in Code::Blocks but I’m not getting it and I don’t understand why. #include <iostream> #include <string> #include <stdlib.h> #include…
-
1
votes1
answer180
viewsProblems scanning strings within the switch (C) command
I’m trying to make a program that encodes and decodes strings that are given by the user by the César cipher method, using switch-case to select what should be done, but when trying to read a string…
-
1
votes3
answers221
viewsError in "switch case"
I have a mistake in one of cases of switch, the mistake is this: I’m doing a CRUD from a library, so when you see the code, maybe you think something’s weird: I made some switch with only 1 option,…
-
1
votes1
answer1113
viewsProblem with switch menu case and while
My goal is that after I run one of the menu options and say I don’t want to continue on it, I can insert another option (or the same if I want to go back). My code runs the first option I type but…
-
1
votes1
answer136
viewsOptimize Java code
Good, I am creating an alarm on android e I wanted to know if inves to have to make a switch for each editText se Avia way to check all on a single switch, I tried with a for and was incremented,…
-
1
votes1
answer147
viewsSwitch command does not work and shows no errors
I’m trying to solve the following exercise: Devise an algorithm that assists in controlling a cattle farm that has a total of 2,000 head of cattle. The database consists of a set of structures…
-
1
votes2
answers2198
viewsProgram Ignoring the Scanf
I need to create an algorithm as requested below, but every time I run the program it "skips" steps. For example: I want you to stay like this Product: "Potato" Sector: "Food" Quantity: "15" Price:…
-
1
votes1
answer127
viewsCommand "switch" enters falls into "default"
For any value you enter, the result is always "None of the alternatives", where the error is? Follows the code: <body> <p>Clique para exibir...</p> <!-- <button…
-
1
votes2
answers522
viewsInfinite loop on switch
The problem is that in all three cases, cout repeats endlessly. #include<iostream> using namespace std; #include<locale.h> int main(){ setlocale(LC_ALL, "Portuguese"); bool a; int…
-
1
votes0
answers56
viewsWhy doesn’t my switch generate the right results?
I’m using a condition and a switch to determine some values for some variables, but I’m not getting the expected results. When the link <a href="index.php?post=myFile"></a> is clicked, I…
-
1
votes1
answer62
viewsExecution error on switch
#include <stdio.h> #include <math.h> int main () { int n1, n2, operacao, soma, sub, mult; float div; printf("Escolha a opecaracao que deseja realizar: ");…
-
1
votes1
answer32
viewsReceive the numeric keys to make some functions equal for all of them on the switch in a calculator
switch (e.target.value) { case "A/C": console.log('ae') break; case "C": break; case "X": break; case ".": break; case "%": break; case "-": break; case "√": break; case "+": break; case "÷": break;…
-
1
votes1
answer116
viewsHow do you make an array of Labels in C/C++?
It is a fact that exists in Assembly (Nasm) and it is a fact that this is a quick way to follow to a point of the program among several. Here is an example code for x64 where you choose one of five…
-
1
votes2
answers77
viewsDoubt about switch
I would like the switch show me the sum if I choose case 1 as follows the code, but it does not perform the operations. #include<stdio.h> int main() { int a,b; int operacao; int soma = a + b;…
-
1
votes1
answer50
viewschar returns invalid typed number as option
opa good afternoon, I am developing a menu in which the option typed is a char, the same returns the default correctly after typing a letter, however, my switch has 7 case options ('1',…
-
0
votes1
answer155
viewsCheck if an element exists with switch
Hello, how do I make a check and check if certain element exists using switch? To be more specific, I’m trying to use this code: var forumversion = function() { invision =…
-
0
votes1
answer96
viewsSwitch in Application.ini ZF 1 configuration
Inside the Zend Framework 1 Application.ini I have the following configuration: resources.multidb.sga.adapter = "PDO_MYSQL" resources.multidb.sga.host = "host.acula.net"…
-
0
votes0
answers122
viewsUpdate a Switch from a Dialog
I have a dialog like this: public void Dialogo_Iluminacao() { final Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.dialogo_iluminacao); dialog.setTitle("Iluminação"); final Switch…
-
0
votes1
answer123
viewsDoubt of Switch
I have a dialog with Switch and programmed with Click to change and now I need to do the same thing when the user drags the Switch off to on or the other way. public void Dialogo_Setor() {…
-
0
votes1
answer793
viewsCode structure problem within switch case
When choosing option 1 (easy) the program enters case 1 correctly, but when I choose the port (0, 1 or 2) it goes back to the menu, the goal is that if the port is the right one it passes to the…
-
0
votes1
answer51
viewsuse of regex on a switch
I’m trying to use regular expressions to validate a switch, but it occurs to me on the console that "day.match" is not a Function: function dayOfWeek(day){ var regex = /[1-7]/g;…
-
0
votes0
answers77
viewsAndroid studio, Switch method hangs app
I’m having a problem with the Switch of Android studio, I just can’t do a manipulation with the data of it because it simply hangs the App on the VM. MAIN.Java a doubt, these changes are in…
-
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
answer368
viewsAngular JS - an ng-model directive template does not work within ng-switch
To get more dynamic my directive decided to include the category field that makes the selection of the type of template to be displayed. As it is just a select thought to use ng-switch instead of…
-
0
votes1
answer35
viewsColor recognition with switch/case
In my code, I’m making a map in which one pixel for colored x, then the Sprite x will be put in it, example: int pixelAtual = pixels[xx + (yy * map.getWidth())]; tiles[xx + (yy * WIDTH)] = new…
-
0
votes2
answers202
viewsForce while loop output on C switch
Guys, I made a menu in C language, but I need that when the user type option 4, it comes out of the repetition loop of/while, someone can help me. Thanks again to all for participating. int opcao;…
-
0
votes1
answer84
viewsIs there any alternative to a giant parole other than by switch case?
$metodo = array( "1"=> fazMetodo1(), //retorna algum valor "2"=> fazMetodo2(), //retorna algum valor "3"=> fazMetodo3() //retorna algum valor //... assim vai ); $inputId = "2"; if…
-
0
votes1
answer162
viewsFormat Switch in Power BI (DAX)
good night! I’m new to DAX and I’d like a hand with the following question: Meta Formatada = SWITCH (KPI.Formatacao , "Money", FORMAT([Meta],"Currency") , "Numeric", FORMAT([Meta],"General Number")…
-
0
votes1
answer69
viewsText changes on the label with switch
You know that initial Pokemon conversation? "Welcome to the world Pokemon" - ENTER "Are you a girl or a boy?" -Enter CONTINUES.... So, I’m trying to do a Java swing, at the moment it’s like this:…
-
0
votes1
answer63
viewsHow to capture several exceptions with C#switch?
I want to capture some exceptions using try-catch and switch. I made a few attempts, but it didn’t work. For example: try { //tarefas... } catch (Exception ex) { switch () { case PrimeiraExceção;…
-
0
votes2
answers728
viewsSwap elseif code for switch case
I’m having trouble modifying a code I made in else if for switch case. I’m not getting the code to work, he gets values and operation by $_GET and does the selected operation: I leave the code here:…
-
0
votes1
answer59
viewsCounters are not being incremented in code
I am facing some difficulties with the code snippet below: The call of this function is: cache = OperaCache(true , endereco, op, cache, descricao, read_hits, read_misses, write_hits, write_misses);…