Sei sulla pagina 1di 28

UNIVERSIDAD DE CONCEPCIN

Depto. Ingeniera Informtica y Ciencias de la Computacin

Lenguaje de Programacin:
Laboratorio 2
Fecha: 24-Mar-2014
Cdigo: 503.195
Encargado Laboratorio: Vctor San Juan

Marzo 2014 Concepcin

Lenguaje de Programacin: Laboratorio 2

Resumen Laboratorio 1.
Etapas de la programacin.
Definicin algoritmo: Conjunto de instrucciones para resolver
un problema.
Expresiones aritmticas
Expresiones lgicas
Operacin de asignacin
Pseudo-cdigo
Smbolos normalizados de diagrama de flujo.
Cdigo MatLab simple.
UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Diagrama de flujos
Smbolos normalizados.
Terminales

Entradas y salidas

UNIVERSIDAD DE CONCEPCIN

Operaciones

Lenguaje de Programacin: Laboratorio I

Ejercicios Laboratorio
Cdigo en MatLab

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Laboratorio 2
Contenidos
Diagrama de flujo
Estructuras selectivas
Simple
Doble

Estructura selectiva mltiple


Test 01
UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Diagrama de flujos.
Herramienta semi-grfica que permite
representar un algoritmo.
Independiente del lenguaje de programacin
utilizado.
Utiliza
smbolos
normalizados
para
representar las operaciones que puede
realizar el computador.

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Diagrama de flujos
Smbolos normalizados.
Terminales

Entradas y salidas

UNIVERSIDAD DE CONCEPCIN

Operaciones

Lenguaje de Programacin: Laboratorio I

Diagrama de flujos
Smbolos normalizados.
Selectivas

Repetitivas

Reagrupamiento

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Ejemplo de algoritmo selectivo.


Problema: Determinar si un nmero N es par
Leo el nmero y le asigno la variable N
Si N es divisible por 2
N es un numero par
Fin
UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Estructura selectiva simple


Se utilizan para que el programa tome decisiones a
partir de la evaluacin de expresiones lgicas.

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Ejemplo estructura selectiva simple.


Problema: Saber si una variable N es mayor que
cero.

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Estructura selectiva doble.

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Ejemplo selectivo doble


Problema: Imprimir si la variable N es positiva o
negativa.

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Cdigo MatLab selectivo doble

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Ejercicio.

Problema: Determinar si una variable N es


mayor que cero, pero menor que 11.

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Soluciones
F

V
F
V

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Soluciones.

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Soluciones
F

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Estructura selectiva mltiple.

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Estructura selectiva mltiple.

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Ejemplo selectivo mltiple.


Problema: Determinar si la variable N es igual a
1, 2, 3 u otro valor cualquiera.

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Solucin, Diagrama de Flujo


F
F

V
V

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Solucin, Cdigo MatLab

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Solucin
1

otro

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Ejercicio
Hacer diagrama de flujo para un programa
que entregue el valor absoluto de un nmero
N y lo muestre en pantalla.
Escribir cdigo MatLab de este diagrama de
flujo.

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Solucin

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Resumen
Estructuras selectivas
if
else
elseif

switch
case
otherwise

end

UNIVERSIDAD DE CONCEPCIN

Lenguaje de Programacin: Laboratorio I

Lenguaje de programacin
Laboratorio 2.

FIN
UNIVERSIDAD DE CONCEPCIN

Potrebbero piacerti anche