Lógica de Programación COIS 115 Profesor: Gustavo Velez.
-
Upload
felisa-blanco-padilla -
Category
Documents
-
view
219 -
download
0
Transcript of Lógica de Programación COIS 115 Profesor: Gustavo Velez.
![Page 1: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/1.jpg)
Lógica de Programación
COIS 115Profesor: Gustavo Velez
![Page 2: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/2.jpg)
![Page 3: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/3.jpg)
Taller Dos
COIS 115Profesor: Gustavo Velez
![Page 4: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/4.jpg)
Variables y Constantes
Variable Su valor cambia durante la
ejecución del programa Constante
Su valor no cambia durante la ejecución del programa
![Page 5: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/5.jpg)
Ejemplos
área = radio2 * Pi
Variables son área y radio
Constante es Pi(3.141593)
![Page 6: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/6.jpg)
Literal constant
Numeric 1, 2.5, -3.9
Character ‘X’, ‘G’, ‘ ‘
String ‘Hello’, ‘Enter age’
![Page 7: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/7.jpg)
Data type
char one character
short integer (2 bytes, 32,768 to 32,767)
int integer (billion -/+)
float floating point single precision
double floating point double precision
![Page 8: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/8.jpg)
Data type
string more characters bool boolean value
![Page 9: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/9.jpg)
Implicit type conversion
Cuando el computar convierte el ‘data type’ del valor asignado al tipo de memoria
Ejemplo Variable int age tiene un valor de 9 La localidad en memoria es ‘float’ El computador lo cambia a 9.0
![Page 10: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/10.jpg)
Explicit type conversion
Convert class Class – grupo de instrucciones para crear un
objeto Crea un objeto que va ha ser un numero o un
‘string’ dependiendo del metodo utlizado
![Page 11: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/11.jpg)
Explicit type conversion
Convert class Método es una porción del las instrucciones de
la clase y cuyo propósito es ejecutar una tarea de la clase
Ejemplos Convert::ToDouble(Value) Convert::ToSingle(Value) Convert::ToString(Value)
![Page 12: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/12.jpg)
Fundamentos de C++
Operaciones estándares Aritméticas
Suma (+), Resta (-), Multiplica (*), Divide (/) y Remanente (%)
Datos numéricos enteros y reales
![Page 13: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/13.jpg)
Fundamentos de C++
Operaciones aritméticas (Cont.) Orden de las operaciones aritméticas
Operaciones entre paréntesis Paréntesis en paréntesis los de adentro van primero)
Las operaciones de *, /, % van después Las operaciones de + y – van ultimas
![Page 14: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/14.jpg)
Fundamentos de C++
Operaciones aritméticas - ejemplos 3 * (-5)
4*5-10
10/3
![Page 15: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/15.jpg)
Fundamentos de C++
Operaciones aritméticas - ejemplos 9%3
-21/(-2)
21%2
4*5/2+5%2
![Page 16: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/16.jpg)
Fundamentos de C++
Operaciones Booleanas Relaciónales
= == Igual que ≠ != No igual que < < Menor que ≤ <= Menor e igual que > > Mayor que ≥ >= Mayor e igual que
![Page 17: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/17.jpg)
Fundamentos de C++
Operaciones Booleanas Relaciónales – ejemplos
5==5
0.025>=0.333
3!=3
![Page 18: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/18.jpg)
Fundamentos de C++
Operaciones Booleanas Relaciónales – ejemplos
-45.2<-3
‘A’<‘Z’
Si x=25; y=-10; x<=y
![Page 19: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/19.jpg)
Fundamentos de C++
Operaciones Booleanas Lógicas
NOT ! OR || AND &&
![Page 20: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/20.jpg)
Fundamentos de C++
Operaciones Booleanas Lógicas - ejemplos
A – cierto; NOT A (!A) Falso
A – falso; NOT A (!A) Cierto
![Page 21: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/21.jpg)
Fundamentos de C++
Operaciones Booleanas Lógicas - ejemplos
A – cierto; B – cierto A OR B (A || B)
A – cierto; B – falso A OR B (A || B)
A – falso; B – cierto A OR B (A || B)
A – falso; B – falso A OR B (A || B)
![Page 22: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/22.jpg)
Fundamentos de C++
Operaciones Booleanas Lógicas - ejemplos
A – cierto; B – cierto A AND B (A && B)
A – cierto; B – falso A AND B (A && B)
A – falso; B – cierto A AND B (A && B)
A – falso; B – falso A AND B (A && B)
![Page 23: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/23.jpg)
Fundamentos de C++
Operaciones de incrementación y decrementación Incremetación ++
++x => x=x+1 Decrementación --
--x => x=x-1
![Page 24: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/24.jpg)
Fundamentos de C++
Funciones matemáticas abs() valor absoluto acos() el coseno asin() seno del arco atan() tangente del arco sqrt() la raíz cuadrada
![Page 25: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/25.jpg)
Fundamentos C++
Produciendo resultados de salida Console::Write(formatstring,
variablelist) Console::WriteLine(formatstring,
variablelist )
![Page 26: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/26.jpg)
Fundamentos C++
Produciendo resultados de salida Ejemplos: Console::Write(name) Console::WriteLine(‘My name is ‘, name) Console::WriteLine(‘My age is {0} ‘, age,
name) Console::WriteLine(‘My age is {0} ‘,
Convert::ToString(age), name)
![Page 27: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/27.jpg)
Fundamentos C++
Produciendo resultados de salida Console::ReadLine( )
Ejemplos inputnumber = Console::ReadLine() number = Convert::ToInt32(inputnumber) number =
Convert::ToInt32(Console::ReadLine())
![Page 28: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/28.jpg)
Case Two
Una empresa desea saber el nuevo aumento de sus empleados. Se informara el salario actual semanal y el por ciento de aumento. Se calculara el nuevo salario.
![Page 29: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/29.jpg)
Input Processing Output
IPO Chart
![Page 30: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/30.jpg)
Asignación
Taller Dos Calcular el promedio de tres números
![Page 31: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/31.jpg)
Asignación
Taller Tres Una liga necesita calcular el promedio de
bateo de sus jugadores. Se pedirá los turnos al bate y los hits conectados. Se informara el promedio del bateador
![Page 32: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/32.jpg)
Preguntas
![Page 33: Lógica de Programación COIS 115 Profesor: Gustavo Velez.](https://reader036.fdocument.pub/reader036/viewer/2022081513/5665b4eb1a28abb57c94ca59/html5/thumbnails/33.jpg)
Check-out
+ (Positive) ∆ (Change) ---------------------------!----------------------------