La descarga está en progreso. Por favor, espere

La descarga está en progreso. Por favor, espere

int cantidad, horas, cuota; float precio, peso; cantidad = 5; // Le asigno un número a la variable Cantidad; horas = 10+20 // Le asigno 30 a la variable.

Presentaciones similares


Presentación del tema: "int cantidad, horas, cuota; float precio, peso; cantidad = 5; // Le asigno un número a la variable Cantidad; horas = 10+20 // Le asigno 30 a la variable."— Transcripción de la presentación:

1

2

3 int cantidad, horas, cuota; float precio, peso; cantidad = 5; // Le asigno un número a la variable Cantidad; horas = 10+20 // Le asigno 30 a la variable horas cuota = Cantidad // A cuota le asigno lo que tiene Cantidad precio= 2,5 // A precio le asigno 2,5 peso= precio + 5 // Esta bien asignado A medida que una variable recibe un valor, pierde su antiguo valor y queda con el nuevo!!!!

4 INTRODUCIR DATOS POR TECLADO Y MOSTRAR DATOS POR PANTALLA Int A; A=100; cout << ‘Hola este es un mensaje’; cout << A; Cout << ‘ El valor de la variable A es: ‘ << A; Cin >> A; Cout <<‘Ingrese un nuevo valor para A:’; Cin >> A

5 Operadores de Comparación en C SintaxisNombre del operador a < b Operador Menor a <= b Operador menor igual a > b Operador Mayor a >= b Operador Mayor Igual a != b Operador Distinto a == b Operador igual a && b Operador Y a || b Operadro O

6 Operación Lógicas: Una comparación lógica devuelve VERDADERO o FALSO (true o false) (1 o 0) int A, B; char C; A= 10; B = 5; C= ‘R’ (A>B) ? (B == B) ? (A>10) ? (C != ‘J’) ? (A<(B+5) ) ? (C > ‘S’) ?

7 CONECTORES LOGICOS && (Y) ||(O) Y(&&)Resultado VVV VFF FVF FFF O(||)Resultado VVV VFV FVV FFF

8 Operación Lógicas con conectores lógicos int A, B; A= 20; B = 5; (A==20) && (B>5) V F V && F F

9 Expresión Condicional IF - ELSE (si) If (CONDICION) { INSTRUCCIONES } ELSE { INSTRUCCIONES } INSTRUCCIONES … If (CONDICION) { INSTRUCCIONES } INSTRUCCIONES …

10 Estructura de Repetición : While WHILE { insturcción 1 instrucción 2 instrucción 3 } Instrucciones que se van a repetir

11 Estructura de Repetición : While int i; i=0; while (i < 3) { cout << “HOLA “ << endl; i = i+1; }... ¿Cómo se ejecuta?

12 Estructura de Repetición : While int i; i=0; while (i < 3) { cout << “HOLA “ << endl; i = i+1; }... i

13 Estructura de Repetición : While int i;i=0; while (i < 3) { cout << “HOLA “ << endl; i = i+1; }... i 0

14 Estructura de Repetición : WHILE int i; i=0; while (i < 3) { cout << “HOLA “ << endl; i = i+1; }... i 0

15 Estructura de Repetición : While int i; i=0; while (i < 3) { cout << “HOLA “ << endl; i = i+1; }... i 0

16 Estructura de Repetición : While int i; i=0; while (i < 3) { cout << “HOLA “ << endl; i = i+1; }... i 1

17 Estructura de Repetición : While int i; i=0; while (i < 3) { cout << “HOLA “ << endl; i = i+1; }... i 1

18 Estructura de Repetición : While int i; i=0; while (i < 3) { cout << “HOLA “ << endl; i = i+1; }... i 1

19 Estructura de Repetición : While int i; i=0; while (i < 3) { cout << “HOLA “ << endl; i = i+1; }... i 2

20 Estructura de Repetición : While int i; i=0; while (i < 3) { cout << “HOLA “ << endl; i = i+1; }... i 2

21 Estructura de Repetición : While int i; i=0; while (i < 3) { cout << “HOLA “ << endl; i = i+1; }... i 2

22 Estructura de Repetición : While int i; i=0; while (i < 3) { cout << “HOLA “ << endl; i = i+1; }... i 3

23 Estructura de Repetición : While int i; i=0; while (i < 3) { cout << “HOLA “ << endl; i = i+1; }... i 3

24 Estructura de Repetición : While int i; i=0; while (i < 3) { cout << “HOLA “ << endl; i = i+1; }... i 3

25 Estructura de Repetición : While int i; i=0; while (i < 3) { cout << “HOLA “ << endl; }...

26 Estructura de Repetición : While char opcion; opcion='J' while (opcion != 'X') { cout << " A - Cargar un alumno nuevo" << endl; cout << " B - Eliminar un alumno del listado" << endl; cout << " C - Cargar notas de un alumno" << endl; cout << " X - Salir del programa" << endl << endl; cout << " Ingrese una opción" << endl; cin >> opcion; if (opción==A) {...} if (opción==B) {...} if (opción==C) {...} }

27 Estructura de Repetición: FOR FOR( inicialización, condición, incremento) { instrucción 1; instrucción 2; instrucción 3; } Instrucciones que se van a repetir

28 Estructura de Repetición : FOR for(int i=0; i<3; i=i+1) { cout << “HOLA “ << endl; }... ¿Cómo se ejecuta?

29 Estructura de Repetición : FOR int i=0 for(int i=0; i<3; i=i+1) { cout << “HOLA “ << endl; }... i 0

30 Estructura de Repetición : FOR i<3 for(int i=0; i<3; i=i+1) { cout << “HOLA “ << endl; }... i 0

31 Estructura de Repetición : FOR for(int i=0; i<3; i=i+1) { cout << “HOLA “ << endl; }... i 0

32 Estructura de Repetición : FOR i=i+1 for(int i=0; i<3; i=i+1) { cout << “HOLA “ << endl; }... i 1

33 Estructura de Repetición : FOR i<3 for(int i=0; i<3; i=i+1) { cout << “HOLA “ << endl; }... i 1

34 Estructura de Repetición : FOR for(int i=0; i<3; i=i+1) { cout << “HOLA“ << endl; }... i 1

35 Estructura de Repetición : FOR i=i+1 for(int i=0; i<3; i=i+1) { cout << “HOLA“ << endl; }... i 2

36 Estructura de Repetición : FOR i<3 for(int i=0; i<3; i=i+1) { cout << “HOLA“ << endl; }... i 2

37 Estructura de Repetición : FOR for(int i=0; i<3; i=i+1) { cout << “HOLA“ << endl; }... i 2

38 Estructura de Repetición : FOR i=i+1 for(int i=0; i<3; i=i+1) { cout << “HOLA“ << endl; }... i 3

39 Estructura de Repetición : FOR i<3 for(int i=0; i<3; i=i+1) { cout << “HOLA“ << endl; }... i 3

40 Estructura de Repetición : FOR for(int i=0; i<3; i=i+1) { cout << “HOLA“ << endl; }... i 3

41 Estructura de Repetición: FOR FOR( int i=50, i>0, i=i-2) { instrucción 1; instrucción 2; instrucción 3; } La variable i va a ir descontandose de 2 en dos: 50, 48, 46, …, 0

42 FORMAS CORTAS DE PONER INCREMENTADORES O DECREMENTADORES i=i+1  i++ i=i-1  i-- for(int i=0; i<3; i++) { cout << “HOLA “ << endl; }... int i; i=0; while (i < 3) { cout << “HOLA “ << endl; i++; }...


Descargar ppt "int cantidad, horas, cuota; float precio, peso; cantidad = 5; // Le asigno un número a la variable Cantidad; horas = 10+20 // Le asigno 30 a la variable."

Presentaciones similares


Anuncios Google