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
1 answer

PL/pgSQL control structures for lists / arrays

Is it possible to use something like this in Postgres? This is the example from PL/SQL what I want to do: PROCEDURE CREATE_PAYMENT(P_AMOUNT IN NUMBER, P_INVOICE_LIST IN SIMPLEARRAYTYPE, …
Maki
  • 471
  • 2
  • 8
  • 17
0
votes
3 answers

While loops expression

I'm trying to write a program that asks the user to enter digits between 0 and 1000000 and it outputs the occurrence of a certain number (that the user entered as well) I've wrote this program and I believe it works well, but I have one issue which…
Noor AIH
  • 25
  • 3
0
votes
3 answers

Converting number to words in Java. Is there an easier and more efficient way to do it?

Hi guys i'm trying to write a simple program using control structures to convert numbers to words but the program is becoming way too long. Is there a simpler way to write it? An example is, if a user inputs 123 the output should be one two three. I…
Manisha Singh Sanoo
  • 919
  • 1
  • 13
  • 42
0
votes
1 answer

How to Implement a Decision Table in Objective-C

I am a novice programmer, and I've just started reading about decision tables. I have read Chapter 18 in Code Complete and it was very enlightening. I looked around the web to try to find any kind of example of decision tables in Objective-C and I…
bazola
  • 270
  • 5
  • 16
0
votes
2 answers

How to get to if modifier's variables?

Consider the following working code: md = nil begin puts md[:c] break end if md = /(?string)/.match('some string') But it kind of looks ugly. Or not? I started with this one: puts c if /(?string)/ =~ 'some string' But it didn't see c…
x-yuri
  • 16,722
  • 15
  • 114
  • 161
0
votes
1 answer

Use namespace within control structure (if-statement)

This works: require_once( $_SERVER["DOCUMENT_ROOT"] . '/fb/FacebookSession.php' ); use Facebook\FacebookSession; This doesn't: if (1 == 1) { require_once( $_SERVER["DOCUMENT_ROOT"] . '/fb/FacebookSession.php' ); use…
user1322720
0
votes
2 answers

Python if else exception over XML parsed with ElementTree

I have the following XML which I have parsed from a webpage: 151 BBa_B0034
Charon
  • 2,344
  • 6
  • 25
  • 44
0
votes
1 answer

Programming Models in R

I asked my original question incorrectly, so here is the better version. I would like to generate a model using R. The gist of the model --> A polymer can grow or shrink at different rates. Every now and then the rate of shrinking increases by 20…
user2813055
  • 283
  • 4
  • 13
0
votes
1 answer

Program simple simulation in R

Editing this post for simplification according to @agstudy I am trying to develop a model that simulates a polymer using a random uniform distribution. The model has 2 states State 1 (probability of state 1 if in state 2 is .003): growth…
user2813055
  • 283
  • 4
  • 13
0
votes
1 answer

Javascript: Assigning a variable and testing it at the same time

In PHP, we can assign a variable AND test it at the same time: find()) { $this->do_something($result); } function find() { if ($this->day == 'Sunday') return '1234'; else return false; } In the…
pbarney
  • 2,529
  • 4
  • 35
  • 49
0
votes
3 answers

Unreachable Code Detected C#

Im trying to Post an unlimited number of likes but looping the cookies and proxies based on the how many cookies are stored in the array. Apparently i++ is unreachable code. What is the reason for that? public void PostLikes() { PostLike postLike…
0
votes
2 answers

How I keep run the program

I'm here again.I'm newbie and I have some questions. I have a code like that, enter = input("Please type something: ") if enter == "1": print("Hello") else: print("Error") How I keep run the program after else. So How I do when I type…
0
votes
3 answers

Basic Java control structure issue.

I'm a college freshmen and I'm having trouble with my programming homework. The homework I got from my lecturer was for me to write a program in Java to take in a student's info, and allow the student to choose how many subject the student takes,…
JLWK
  • 65
  • 1
  • 9
0
votes
1 answer

Bash: Search a script for a block of commands and then execute those commands

I have a script, named bundle, which uses Here-documents to combine text files into a single file. The files, whose names are passed as arguments when calling the bundle script, are placed within a single file (here named filebundle) which can then…
primussucks
  • 293
  • 2
  • 5
0
votes
4 answers

Issue with if /elseif /else

I am creating a whitelist if you will for a user to input data. I am getting stuck on the elseif statements. This is my code : public function is_valid_data($data) { if(strlen($data > 9)) { $this -> set_message('is_valid_data',…
user2406611
  • 35
  • 1
  • 6