1 1 4 Enunciados de control Apoyo SSD3
Control and Selection <ul><li>By default, statements in a program are executed sequentially in the order that they appear....
If-Else <ul><li>The general selection structure in Java is the if-else-statement. It has the following form. </li></ul><ul...
Operator ?: <ul><li>There is an operator that is often confused with the if-else-statement, the conditional operator (&quo...
Operator ?: <ul><li>If  condition  is true,  variable  is assigned the value of  exp1 ; otherwise  variable  is assigned t...
Switch <ul><li>There is one other selection construct available in Java, the switch-statement. It has the following form. ...
For <ul><li>The for-loop has the following form. </li></ul><ul><ul><li>for (initialization; condition; update) { </li></ul...
<ul><li>When a for-loop is encountered, the initialization occurs just once and foremost.  </li></ul><ul><li>Then, the con...
<ul><li>Then, the condition is retested, and the cycle continues. </li></ul><ul><li>When the condition becomes false, the ...
While <ul><li>The while-loop has the following form. </li></ul><ul><ul><li>initialization </li></ul></ul><ul><ul><li>while...
Do-While <ul><li>The do-while loop has the following form. </li></ul><ul><ul><li>initialization </li></ul></ul><ul><ul><li...
Upcoming SlideShare
Loading in …5
×

1 1 4 Enunciados De Control

487
-1

Published on

Published in: Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
487
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

1 1 4 Enunciados De Control

  1. 1. 1 1 4 Enunciados de control Apoyo SSD3
  2. 2. Control and Selection <ul><li>By default, statements in a program are executed sequentially in the order that they appear. </li></ul><ul><li>Programming languages provide control structures to alter this default. </li></ul><ul><li>Selection is used to conditionally prevent the execution of a statement. </li></ul>
  3. 3. If-Else <ul><li>The general selection structure in Java is the if-else-statement. It has the following form. </li></ul><ul><ul><li>if (condition) { </li></ul></ul><ul><ul><li>statements1 </li></ul></ul><ul><ul><li>} else { </li></ul></ul><ul><ul><li>statements2 </li></ul></ul><ul><ul><li>} </li></ul></ul>
  4. 4. Operator ?: <ul><li>There is an operator that is often confused with the if-else-statement, the conditional operator (&quot;?:&quot;). Below is an indication of its use. </li></ul><ul><li>variable = condition ? exp1 : exp2; </li></ul>
  5. 5. Operator ?: <ul><li>If  condition  is true,  variable  is assigned the value of  exp1 ; otherwise  variable  is assigned the value of  exp2 </li></ul>
  6. 6. Switch <ul><li>There is one other selection construct available in Java, the switch-statement. It has the following form. </li></ul><ul><ul><li>switch (expresión entera) { </li></ul></ul><ul><ul><li>case cie1: </li></ul></ul><ul><ul><li>statements1 </li></ul></ul><ul><ul><li>case cie2: </li></ul></ul><ul><ul><li>statements2 </li></ul></ul><ul><ul><li>... </li></ul></ul><ul><ul><li>case cien: </li></ul></ul><ul><ul><li>statementsn </li></ul></ul><ul><ul><li>default: </li></ul></ul><ul><ul><li>statementsd </li></ul></ul><ul><ul><li>} </li></ul></ul>
  7. 7. For <ul><li>The for-loop has the following form. </li></ul><ul><ul><li>for (initialization; condition; update) { </li></ul></ul><ul><ul><li>statement </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><li>The statement, of course, can be a compound statement. </li></ul><ul><li>Notice that the semicolons are separators, not terminators. </li></ul>
  8. 8. <ul><li>When a for-loop is encountered, the initialization occurs just once and foremost. </li></ul><ul><li>Then, the condition is evaluated. If the condition evaluates to true, the body is executed, followed by the update. </li></ul>
  9. 9. <ul><li>Then, the condition is retested, and the cycle continues. </li></ul><ul><li>When the condition becomes false, the loop is exited. If the condition never becomes false, an infinite-loop occurs. </li></ul><ul><li>This is generally undesirable </li></ul>
  10. 10. While <ul><li>The while-loop has the following form. </li></ul><ul><ul><li>initialization </li></ul></ul><ul><ul><li>while (condition){ </li></ul></ul><ul><ul><li>body </li></ul></ul><ul><ul><li>update </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><li>Since the update typically appears in the body of the while loop, the while loop often uses a compound statement. </li></ul>
  11. 11. Do-While <ul><li>The do-while loop has the following form. </li></ul><ul><ul><li>initialization </li></ul></ul><ul><ul><li>do { </li></ul></ul><ul><ul><li>body </li></ul></ul><ul><ul><li>update </li></ul></ul><ul><ul><li>} while (condition); </li></ul></ul><ul><li>The do-while loop is similar in structure to a while-loop, except in its upside-down appearance, as the condition appears after the body. </li></ul>

×