Questions tagged [control-structure]

Within an imperative programming language, a control flow statement is a statement whose execution results in a choice being made as to which of two or more paths should be followed.

Within an imperative programming language, a control flow statement is a statement whose execution results in a choice being made as to which of two or more paths should be followed.

The kinds of control flow statements supported by different languages vary, but can be categorized by their effect:

  • continuation at a different statement (unconditional branch or jump),
  • executing a set of statements only if some condition is met (choice - i.e., conditional branch),
  • executing a set of statements zero or more times, until some condition is met (i.e., loop the same as conditional branch),
  • executing a set of distant statements, after which the flow of control usually returns (subroutines, coroutines, and continuations),
  • stopping the program, preventing any further execution (unconditional halt).

from Wikipedia

138 questions
0
votes
2 answers

How to evaluate each value in an array all true and do something in that case in Php?

I need to insert more than one row in a table foreach($answers as $answer){ $sql =<<
mko
  • 21,334
  • 49
  • 130
  • 191
0
votes
1 answer

stsClass objects inside array

I var_dumped a variable and got this, how can i show it properly? Like,

Name: Country:

object(stdClass)#19 (3) { …
NestedWeb
  • 1,657
  • 2
  • 15
  • 31
0
votes
3 answers

Perl Case statement for a range of dates

I have this PERL Switch..case statement: switch ($today) { case "14-Aug-2012" { do A } case "15-Aug-2012" { do B } }#end switch My problem is that the "do B" statement is the same for 15-Aug-2012 to like 01-Oct-2012. How do I say case…
user1444664
0
votes
2 answers

jQuery: about booleans in control structures

I have this code: console.log($(domElem).attr('selected')); console.log(typeof $(domElem).attr('selected')); if($(domElem).attr('selected') == true); { alert("there is one element selected"); } The output…
tirenweb
  • 30,963
  • 73
  • 183
  • 303
-1
votes
1 answer

How to create a Sudoku grid with the following pattern in C without arrays?

I have to create a Sudoku grid with the following pattern in C: 1 2 3 4 3 4 1 2 2 3 4 1 4 1 2 3 The first number in the top left corner (here: 1) must be an editable variable for a start value. There is another variable to create the grid with by…
Chipmaster5
  • 274
  • 2
  • 7
-1
votes
1 answer

postgresql for loop script in text form can not be executed

I am trying to write function in postgresql, that creates temp_table with columns table_name text, table_rec jsonb and fill it through for loop with table names from my table containing names of tables and records in json. I have the for loop in…
kony51
  • 3
  • 3
-1
votes
1 answer

What have I missed in this while-loop?

I am trying to write a simple program that reads a name as a C-style string. The name is then printed vertically, one character per line. Currently when the program prompts a user to enter their name, eg. Henry James, only 'Henry' is printed…
Dinomo
  • 11
  • 1
-1
votes
2 answers

toUpperCase(char) method?

I have seen this question asked a lot on here but I can't seem to figure out why my code doesn't work when the input are lower case characters. When I input lower case characters it seems to execute endlessly until I terminate it. I have used the…
Kurtis
  • 7
-1
votes
3 answers

Endless JavaScript ELSE IF statement 650 Need shortening

I need to modify some script that runs in a program I use. The script ONLY plots horizontal lines at specific prices on a chart that has an X & Y axis. Whenever I switch to a new chart, the script will run through all the statements until it gets to…
-1
votes
2 answers

Regular expression handling in elsif block in perl

GMF File: TSTARTCUSTEVSUMMROW_GPRS CUSTEVSUMMROW_GPRS GPRS - Subscriber Package (Paygo)|93452|MB|240|33952 CUSTEVSUMMROW_GPRS GPRS - MBB Plan (Paygo)|93452|MB|160|20128 TENDCUSTEVSUMMROW_GPRS TSTARTCUSTEVSUMMROW_GPRS_SIMPLE CUSTEVSUMMROW_GPRS_SIMPLE…
user3274607
  • 19
  • 1
  • 1
  • 6
-1
votes
2 answers

Why am I getting this parse error in a PHP if statement?

I am getting this error: Parse error: syntax error, unexpected '!=' (T_IS_NOT_EQUAL) in C:\xampp\htdocs\assurance\confirmation.php on line 131 Here is lines 131-134 of my code: if ($_POST['password']) != ($_POST['confirm']) { echo '
-1
votes
1 answer

Control structures are failing me

I am trying to make a simple Arduino game that keeps track of the number of times a button has been pressed. There are two buttons, one for each user, and whoever is closest to the random number that the Arduino picks, wins. "winning" being a light…
sanch
  • 696
  • 1
  • 7
  • 21
-3
votes
1 answer

Mutliple if else statements to a meaningful data structure

There are plenty of nested if else statements in the legacy code (VB Script) which I want to migrate to a meaningful representation for easier maintenance in a Java application. Most of these statements are used to generate a sql statement based on…
Cid
  • 1,453
  • 1
  • 18
  • 37
-3
votes
2 answers

PHP goto control structure infinite execution

This seems to execute like an infinite loop. a: echo "Statement 1 \n"; b: echo "Statement 2 \n"; if(1 > 2) goto a; else goto b; But this works correctly. if(1 > 2) goto a; else goto b; a: echo "Statement 1 \n"; b: …
웃웃웃웃웃
  • 11,829
  • 15
  • 59
  • 91
-4
votes
1 answer

Behavior of break statement

#include #include void main() { int i, j, k, l; i = j = 0; clrscr(); for(k = 0; k < 3; k++) { printf("Flag A\t"); for(l = 0; l < 2; l++) { printf("Flag B\t"); …
SumS
  • 25
  • 6
1 2 3
9
10