1 / 12

EL LENGUAJE DE PROGRAMACIÓN C

EL LENGUAJE DE PROGRAMACIÓN C. Tipos de datos:. INT: números enteros de 8 bits CHAR: datos de 8 bits, principalmente caracteres. LONG: números reales de 16 bits. DOUBLE: números reales de 32 bits. Ej: int a =3; char a=‘a’; long pi = 3.1415;. Arrays:.

armani
Télécharger la présentation

EL LENGUAJE DE PROGRAMACIÓN C

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EL LENGUAJE DE PROGRAMACIÓNC

  2. Tipos de datos: • INT: números enteros de 8 bits • CHAR: datos de 8 bits, principalmente caracteres. • LONG: números reales de 16 bits. • DOUBLE: números reales de 32 bits. Ej: int a =3; char a=‘a’; long pi = 3.1415;

  3. Arrays: • Nos permiten definir bloques de datos del mismo tipo: int primos[] = {1,3,5,7}; int x[2][2]={{1,2},{3,4}}; x[1][2]=3; int a = primos[3]; char mensaje[] = “hola mundo”;

  4. Operadores: • Aritméticos: + - * / % ++ -- • Relacionales y lógicos: > >= < <= == != && || ! • Manejo de bits: &|^<< >> ~

  5. Estructuras de control: • Condicionales. • Decisión múltiple. • Bucles while y do-while. • Bucle for.

  6. Condicionales: if ( portA= = 0x01 ) { a = 3; velocidad++; } else if (portA = = 0x02){ a =2; velocidad --; } else { a =1; }

  7. Decisión múltiple: switch ( c ) { case ‘s’: si(); break; case ‘n’: no(); break; default: error (); }

  8. Bucles while y do-while: while (! cansado) { trabaja (); } do { trabaja (); } while (! cansado);

  9. Bucle for: for (inicialización de variables; condición del bucle; acción al final de cada iteración) for (i=0;i<10;i++) {} for(;;) {} bucle infinito equivalente a while(1);

  10. Funciones: Tipo devuelto nombre (parámetros) {} int cuadrado (int x) { return x*x; } void nada (void){ ... ... return; }

  11. Funciones: • La función principal es la función main: Void main (void){ ... ... } • Las funciones pueden estar en el propio fichero o en otros (librerías). Estos ficheros se pueden incorporar a nuestro código.

  12. Directivas del compilador: • Para definir valores constantes en nuestro código (sustitución textual): #define uno 1 • Para incluir ficheros con librerías: #include <librería.h> #include “librería.h”

More Related