FACTOID # 115: American planes take-off a staggering 8.5 million times per year - almost half the number of take-offs worldwide.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Conditional statement

In computer science, conditional statements are a vital part of a programming language. These statements are requests to the computer to make an execution choice based on a given condition. Computer science, or computing science, is the study of the theoretical foundations of information and computation and their implementation and application in computer systems. ... A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. ... A statement is the minimal unit of structuring in imperative programming languages. ... A BlueGene supercomputer cabinet. ...


One form is the If-Then clause, sometimes seen as :

 If (condition) Then (statements) Else (statements) End If 

It works this way - when the computer finds an If (a reserved word), it expects a data comparison, for example, x = 0 and evaluates the condition. If the condition is true, the statement block following the Then (another reserved word) shall be executed, otherwise the execution shall continue in the following statement block. A reserved word is a word which, in some computer programming language, cannot be used as an identifier because it is already used for some grammatical purpose. ... In computer programming, a statement block (or code block) is a section of code which is grouped together, much like a paragraph; such blocks consist of one, or more, statements. ...


Depending on the language, the If may use Then, brackets, and another clause called Else or ElseIf. See parenthesis for an account of the rhetorical concept from which the name of the punctuation mark is derived. ...


There are many other conditional statements in programming languages, however, all of them follow these principles. Other conditional statements include switch statements, case statements and statements with guards. In computer programming, a switch statement is a type of control statement that exists in most modern imperative programming languages (e. ... In computer programming, a switch statement is a type of control statement that exists in most modern imperative programming languages (e. ... In computer programming, a guard is a boolean expression that must evaluate to true if the program execution is to continue in the branch in question. ...


Alternative Syntax

Main article: Ternary operation

Many languages support alternative syntax for if statements: (condition)?(evaluate if condition was true):(evaluate if condition was false).
This is mainly used for in-line if statements that wouldn't be suitable in the place used, for example: In mathematics, a ternary operation is any operation of arity three, that is, that takes three arguments. ...

 //Invalid $var = if(true) { 'foo' } else { 'bar' }; //Valid $var = (true)?'foo':'bar' 

To accomplish the same as the second (correct) line above, using standard if/else construct:

 if (true) { $var = 'foo'; } else { $var = 'bar'; } 

The alternative syntax can also be used inside if statements themselves: that is to say more generally, "The alternative syntax, accomplishing the equivalent of an analogous if/else construct, may be used anywhere an if/else construct may be appropriately used".


See also


  Results from FactBites:
 
SparkNotes: Logic Statements: Variations Using Statements (546 words)
The negation of the statement "The ball rolls" is "The ball does not roll." By definition, the negation of a statement has the opposite truth value of the original statement.
When two statements are combined with the word "and" the combination of those statements is called the conjunction of two statements.
It is the condition necessary for the conclusion to occur.
Conditional And Iterative Data Types (2947 words)
If statement number two is not true, the next statement is examined; then the next statement is examined and so forth until a condition is met, and the control is carried out of the multi-alternative conditional.
The posttest iterative statement is the same as the pretest statement except the condition is tested after the sequence of statements.
With the in-test iterative statement, the conditional statement is tested in the middle of the sequence of statements.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.