SlideShare una empresa de Scribd logo
1 de 7
UNIDAD EDUCATIVA “12 DE 
FEBRERO”
SEGUNDO DE BACHILLERATO EN 
SISTEMAS
ESTRUCTURAS CONDICIONALES Y 
SELECTIVAS
ELABORADO POR: KATHERINE MONTES 
Y
WILMER ANDRADE
TOMA DE DECISIONES EN 
LENGUAJE C

Con el lenguaje C++ puede tomar decisiones gracias a 2 estructuras:
B. Estructura s w i t c h
A. Estructura i f
Este  tipo  de  sentencias  le  permiten  alterar  la  secuencia  normal  de  pasos  de  su 
programa en base a la redacción
de condiciones específicas.

Estructura i f ­ e l s e para toma de decisiones
A  la  estructura  if  se  le  define  una  condición  para  así  bifurcar  la  secuencia  del 
programa en una de dos
alternativas posibles. De la siguiente manera:
a) Si se cumple la condición ejecutará las if
b) Si no se cumplen la condición, ejecutará las else
La sintaxis de la estructura IF se define así (COMPARE ATENTAMENTE LAS 2 
REDACCIONES):
Lenguaje C

if(condición) {

Comparación con el Pseudocódigo
  
Si (condición) entonces

//Sentencias si cumple condición

Sentencias si cumple condición

Sentencias1

Sentencias 1

}
Else {

Sino

//Sentencias si no cumple condición

Sentencias si no cumple condición

Sentencias2

Sentencias 2

}

Fin Si
Las condiciones a evaluar por una estructura if puede ser de 2 tipos:
a) Simple                                       b) Compleja.
En una Condición simple, se compara una variable con un valor o sino con otra 
variable, gracias a los
operadores relacionales de C++ que son los siguientes:
> mayor que             
< menor que              
>= mayor o igual que
<= menor o igual que
== igual que               
!= Diferente a, No igual que
Una condición compleja permite evaluar 2 o más condiciones simples como una 
sola evaluación lógica, gracias
al uso de los operadores lógicos. Los operadores lógicos de C.
EJEMPLOS
Ejemplos de condiciones complejas utilizando los operadores lógicos 
dentro de un if:
if ((a>5)&&(Z<=12))
if ((Z>5)||(w<1))      
  
               if ((renta<=120)&&(AFP>45))
            if ((a>0)||(b<=0)&&(n != a)) 
Estructura de decisión s w i t c h ­ c a s 
e
La  instrucción  de  selección  switch  es  una  instrucción  de  selección 
múltiple que permite efectuar un grupo de
acciones  según  el  resultado  de  evaluar  solamente  a  una  variable  con 
una serie de valores.
Esta variable al ser evaluada debe proporcionar como
resultado un valor entero o, en ocasiones, un carácter, de lo
contrario generara resultados imprevistos. 
La estructura de una sentencia switch comienza con la palabra
reservada switch seguida de un Variable entre paréntesis. El
valor de esta variable es la que se quiere comparar con una
serie de valores definidos dentro de la sentencia switch.
Luego se definen una pareja de llaves { } que limitan el cuerpo
de switch. A continuación, se utilizan las etiquetas de
selección Case., para definir cada uno de los valores con los
cuales se comparara a la variable. Esta palabra case debe tener
como argumento obligatoriamente constantes enteras, o
caracteres individuales sea bajo forma numérica o simbólica.
Normalmente, la sentencia switch compara en secuencia a la
Variable con el valor definido en cada Case. Si cumple que es
igual al valor definido en un Case particular, desarrolla el
conjunto de Instrucciones definidas luego de los 2 puntos
Respectivos.

La Instrucción Break
Esta  instrucción  se  utiliza  para  producir  una  salida  inmediata  de 
cualquier estructura de control, ya sea selectiva
múltiple  (como  el  switch),  o  para  producir  la  salida  anticipada  de  un 
ciclo o lazo de tipo while, do...while o for.
La ejecución del programa continúa con la primera instrucción fuera de 
la estructura de control suspendida.

Más contenido relacionado

Último

PLAN LECTOR QUINTO 2023 educación primaria de menores Quinto grado
PLAN LECTOR QUINTO 2023  educación primaria de menores Quinto gradoPLAN LECTOR QUINTO 2023  educación primaria de menores Quinto grado
PLAN LECTOR QUINTO 2023 educación primaria de menores Quinto grado
Santosprez2
 
Escucha tu Cerebro en Nuevos Escenarios PE3 Ccesa007.pdf
Escucha tu Cerebro en Nuevos Escenarios  PE3  Ccesa007.pdfEscucha tu Cerebro en Nuevos Escenarios  PE3  Ccesa007.pdf
Escucha tu Cerebro en Nuevos Escenarios PE3 Ccesa007.pdf
Demetrio Ccesa Rayme
 
FICHA DE LA VIRGEN DE FÁTIMA.pdf educación religiosa primaria de menores
FICHA DE LA VIRGEN DE FÁTIMA.pdf educación religiosa primaria de menoresFICHA DE LA VIRGEN DE FÁTIMA.pdf educación religiosa primaria de menores
FICHA DE LA VIRGEN DE FÁTIMA.pdf educación religiosa primaria de menores
Santosprez2
 
Pasos para enviar una tarea en SIANET - sólo estudiantes.pdf
Pasos para enviar una tarea en SIANET - sólo estudiantes.pdfPasos para enviar una tarea en SIANET - sólo estudiantes.pdf
Pasos para enviar una tarea en SIANET - sólo estudiantes.pdf
NELLYKATTY
 

Último (20)

PLAN LECTOR QUINTO 2023 educación primaria de menores Quinto grado
PLAN LECTOR QUINTO 2023  educación primaria de menores Quinto gradoPLAN LECTOR QUINTO 2023  educación primaria de menores Quinto grado
PLAN LECTOR QUINTO 2023 educación primaria de menores Quinto grado
 
Escucha tu Cerebro en Nuevos Escenarios PE3 Ccesa007.pdf
Escucha tu Cerebro en Nuevos Escenarios  PE3  Ccesa007.pdfEscucha tu Cerebro en Nuevos Escenarios  PE3  Ccesa007.pdf
Escucha tu Cerebro en Nuevos Escenarios PE3 Ccesa007.pdf
 
ACERTIJO CÁLCULOS MATEMÁGICOS EN LA CARRERA OLÍMPICA. Por JAVIER SOLIS NOYOLA
ACERTIJO CÁLCULOS MATEMÁGICOS EN LA CARRERA OLÍMPICA. Por JAVIER SOLIS NOYOLAACERTIJO CÁLCULOS MATEMÁGICOS EN LA CARRERA OLÍMPICA. Por JAVIER SOLIS NOYOLA
ACERTIJO CÁLCULOS MATEMÁGICOS EN LA CARRERA OLÍMPICA. Por JAVIER SOLIS NOYOLA
 
FICHA DE LA VIRGEN DE FÁTIMA.pdf educación religiosa primaria de menores
FICHA DE LA VIRGEN DE FÁTIMA.pdf educación religiosa primaria de menoresFICHA DE LA VIRGEN DE FÁTIMA.pdf educación religiosa primaria de menores
FICHA DE LA VIRGEN DE FÁTIMA.pdf educación religiosa primaria de menores
 
4ª SESION la misión santificadora del Espíritu Santo en la vida de la Iglesi...
4ª SESION  la misión santificadora del Espíritu Santo en la vida de la Iglesi...4ª SESION  la misión santificadora del Espíritu Santo en la vida de la Iglesi...
4ª SESION la misión santificadora del Espíritu Santo en la vida de la Iglesi...
 
cuadernillo_cuentos_de_los_valores_elprofe20 (1).docx
cuadernillo_cuentos_de_los_valores_elprofe20 (1).docxcuadernillo_cuentos_de_los_valores_elprofe20 (1).docx
cuadernillo_cuentos_de_los_valores_elprofe20 (1).docx
 
El Futuro de la Educacion Digital JS1 Ccesa007.pdf
El Futuro de la Educacion Digital  JS1  Ccesa007.pdfEl Futuro de la Educacion Digital  JS1  Ccesa007.pdf
El Futuro de la Educacion Digital JS1 Ccesa007.pdf
 
¿Que es Fuerza? online 2024 Repaso CRECE.pptx
¿Que es Fuerza? online 2024 Repaso CRECE.pptx¿Que es Fuerza? online 2024 Repaso CRECE.pptx
¿Que es Fuerza? online 2024 Repaso CRECE.pptx
 
Los caminos del saber matematicas 7°.pdf
Los caminos del saber matematicas 7°.pdfLos caminos del saber matematicas 7°.pdf
Los caminos del saber matematicas 7°.pdf
 
DISEÑO DE ESTRATEGIAS EN MOMENTOS DE INCERTIDUMBRE.pdf
DISEÑO DE ESTRATEGIAS EN MOMENTOS DE INCERTIDUMBRE.pdfDISEÑO DE ESTRATEGIAS EN MOMENTOS DE INCERTIDUMBRE.pdf
DISEÑO DE ESTRATEGIAS EN MOMENTOS DE INCERTIDUMBRE.pdf
 
Pasos para enviar una tarea en SIANET - sólo estudiantes.pdf
Pasos para enviar una tarea en SIANET - sólo estudiantes.pdfPasos para enviar una tarea en SIANET - sólo estudiantes.pdf
Pasos para enviar una tarea en SIANET - sólo estudiantes.pdf
 
TÉCNICAS OBSERVACIONALES Y TEXTUALES.pdf
TÉCNICAS OBSERVACIONALES Y TEXTUALES.pdfTÉCNICAS OBSERVACIONALES Y TEXTUALES.pdf
TÉCNICAS OBSERVACIONALES Y TEXTUALES.pdf
 
ACERTIJO EL NÚMERO PI COLOREA EMBLEMA OLÍMPICO DE PARÍS. Por JAVIER SOLIS NOYOLA
ACERTIJO EL NÚMERO PI COLOREA EMBLEMA OLÍMPICO DE PARÍS. Por JAVIER SOLIS NOYOLAACERTIJO EL NÚMERO PI COLOREA EMBLEMA OLÍMPICO DE PARÍS. Por JAVIER SOLIS NOYOLA
ACERTIJO EL NÚMERO PI COLOREA EMBLEMA OLÍMPICO DE PARÍS. Por JAVIER SOLIS NOYOLA
 
flujo de materia y energía ecosistemas.
flujo de materia y  energía ecosistemas.flujo de materia y  energía ecosistemas.
flujo de materia y energía ecosistemas.
 
Realitat o fake news? – Què causa el canvi climàtic? - Modificacions dels pat...
Realitat o fake news? – Què causa el canvi climàtic? - Modificacions dels pat...Realitat o fake news? – Què causa el canvi climàtic? - Modificacions dels pat...
Realitat o fake news? – Què causa el canvi climàtic? - Modificacions dels pat...
 
Lecciones 07 Esc. Sabática. Motivados por la esperanza
Lecciones 07 Esc. Sabática. Motivados por la esperanzaLecciones 07 Esc. Sabática. Motivados por la esperanza
Lecciones 07 Esc. Sabática. Motivados por la esperanza
 
novelas-cortas--3.pdf Analisis introspectivo y retrospectivo, sintesis
novelas-cortas--3.pdf Analisis introspectivo y retrospectivo, sintesisnovelas-cortas--3.pdf Analisis introspectivo y retrospectivo, sintesis
novelas-cortas--3.pdf Analisis introspectivo y retrospectivo, sintesis
 
4. MATERIALES QUE SE EMPLEAN EN LAS ESTRUCTURAS.pptx
4. MATERIALES QUE SE EMPLEAN EN LAS ESTRUCTURAS.pptx4. MATERIALES QUE SE EMPLEAN EN LAS ESTRUCTURAS.pptx
4. MATERIALES QUE SE EMPLEAN EN LAS ESTRUCTURAS.pptx
 
Power Point : Motivados por la esperanza
Power Point : Motivados por la esperanzaPower Point : Motivados por la esperanza
Power Point : Motivados por la esperanza
 
Estudios Sociales libro 8vo grado Básico
Estudios Sociales libro 8vo grado BásicoEstudios Sociales libro 8vo grado Básico
Estudios Sociales libro 8vo grado Básico
 

Destacado

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Destacado (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

ESTRUCTURA CONDICIONALES