Difference between revisions of "If then else"

From Conservapedia
Jump to: navigation, search
(Visual Basic example)
(rewrite, add another example)
 
Line 1: Line 1:
The '''if then else''' logic of computer programming is the essential aspect which elevated the modern computer from earlier automatic machines such as the [[Jacquard loom]].
+
The "if then else" construct is a form of [[Conditional Statement]] that is most often used in [[Computer Programming]]. This statement is used in almost all modern programming languages. The basic structure of it is:
 +
if condition is true then do x
 +
else do y
  
 
Visual Basic example:
 
Visual Basic example:
Line 8: Line 10:
 
  end if
 
  end if
  
 +
 +
Java Example:
 +
if (x < 4){
 +
  y = z + x;
 +
else{
 +
  y = z;
 +
}
  
 
[[Category:Computer Programming]]
 
[[Category:Computer Programming]]

Latest revision as of 10:35, 26 November 2009

The "if then else" construct is a form of Conditional Statement that is most often used in Computer Programming. This statement is used in almost all modern programming languages. The basic structure of it is:

if condition is true then do x
else do y

Visual Basic example:

if x < 4 then
 y = z + x
else
 y = z
end if


Java Example:

if (x < 4){ 
 y = z + x;
else{
 y = z;
}