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

132 questions
-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
  • 578
  • 1
  • 4
  • 20
-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,383
  • 1
  • 16
  • 35
-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: …
Deepu
  • 11,425
  • 13
  • 53
  • 87
-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
  • 27
  • 6
-5
votes
2 answers

How could I rewrite this selection structure with only if statements?

A problem I have asks to create a program, where a user is to enter an integer value (between 1 and 4) and depending on the input, a specific output is to be generated. It must also provide an error to the user when the value entered is not between…
-5
votes
3 answers

How to - Go Dynamic with PHP

I have a form which actions against a php file. Once the form is completed and the data is inserted into the databse, it want it to display "Awesome". Awesome is being displayed but is above the form. I want it to replace the form and display…
Johnson
  • 9
  • 1
  • 1
  • 8
-5
votes
5 answers

Accessing index when iterating over java array for loop

This is perhaps a random and nitpicky question, but I've been doing a lot of work with array manipulation in Java recently, and I was wondering whether, when using the following loop: for (Object obj : SomeArrayOrCollection) { //do…
nameless912
  • 367
  • 1
  • 12
1 2 3
8
9