Download presentation
Presentation is loading. Please wait.
1
Estructura de Selección
COMP 232 Prof. Carlos Rodríguez Sánchez
2
Flujogramas If selection structure start Price = price * 1.1 F stop
Enter Part number & price T Price = price * 1.1 Part number = “AB203” F Display “Price increase” Display part number & price stop
3
Flujogramas start If/else selection structure A Enter sales T
Display commission T Commission = .02 * sales Sales > 1500 stop F Commission = .01 * sales A
4
Codificando la Estructura de Selección
Formato: if (condición) one statement or a block of statements enclosed in braces, to be processed when the condition is true [else one statement or a block of statements enclosed in braces, to be processed when the condition is false]
5
if (condition) one statement { multiple statements require braces } else multiple statements require braces
6
Operadores de comparación utilizados en C++
Operator Operation Precedence number < <= > >= == != less than less than or equal to greater than greater than or equal to equal to not equal to 1 2
7
Ejemplos if statement’s condition Meaning if (quantity < 50)
if (age >= 25) if (onhand == targed) if (quantity != 7500)
8
Using Comparison Operators in a Program
start a Enter first number & second number Display first number & second number Assign first number to temp T first number > second number Assign second number to first number stop F Assign temp to second number a
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.