








Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Prepara tus exámenes
Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Prepara tus exámenes con los documentos que comparten otros estudiantes como tú en Docsity
Encuentra los documentos específicos para los exámenes de tu universidad
Estudia con lecciones y exámenes resueltos basados en los programas académicos de las mejores universidades
Responde a preguntas de exámenes reales y pon a prueba tu preparación
Consigue puntos base para descargar
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Comunidad
Pide ayuda a la comunidad y resuelve tus dudas de estudio
Ebooks gratuitos
Descarga nuestras guías gratuitas sobre técnicas de estudio, métodos para controlar la ansiedad y consejos para la tesis preparadas por los tutores de Docsity
Asignatura: Programación, Profesor: , Carrera: Ingeniería Electrónica Industrial y Automática, Universidad: UC3M
Tipo: Resúmenes
1 / 14
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!









Machine composed of electronic elements, able to accept data from an input device, to process them automatically with a previously stored program, and to provide the resulting information through an output device Information?
o use different technologies (magnetic signals on hard disk, reflective spots on CD) o memory is permanent – useful for storing long-term data. Input devices allow the computer to receive data and instructions from external sources.
2 19 1 Very fast because talking to the computer with its own
idiom. 2 19 3 Very difficult because we must understand how the exact combination of 1s and 0s will
affect the program. 2 19 3 It cannot be used in different processor CPU, because the instructions use specific
hardware components
of a specific CPU, the same program can be run on different CPU. 2 19 1 The same source program can be executed in different operating systems (but specific
compilers are required for each system) 2 19 3 a program must be translated into binary language, this translation is more complex than
the assembly process.
It transforms the program in a high-level language (source code) to programs in a low-level language (object code) The compiler detects syntax errors; if any, it warns the programmer and the object code is not generated The generated program can be run on any other compatible computer (with the same operating system), even if the compiler is not installed
algorithm created to solve the problem.
Example
Read an integer value (larger than 0) and print all the positive integers lesser than this value. The operation is repeated until the user enters the value 0.
Read an integer value representing a day of the week and print the corresponding name. Ask the user to repeat the procedure.
Declaration and initialization of structures: Values are directly assigned struct Point3D point1 = {2.1, 3.4, 9.8};
Initialization, assignment and copy of structures An array of structures stores a list of entities Different from an array inside a structure! Syntax struct <structure_name> <array_name>[
The entities of the array are grouped together and can be accessed with indexes as any other array element
The members of a structure can be basic or complex data types: integer, character, pointer... array, structure Example Entry of an address book (arrays inside a structure) struct AddressBookEntry { char name[256]; }; char surname[256]; char email[256]; int phone[4]; Example (structures inside a structure, array of structures inside a structure) struct Point2D { float x; float y; }; struct Triangle { struct Point2D a; struct Point2D b; struct Point2D c; }; struct Pentagon { struct Point2D points[5]; };
Syntax Header ) { }
/* Example: Passing parameters by value */ Before calling demo function: n --> 10 Inside demo function: value --> 10 Inside demo function: value --> 999 After calling demo function: n --> 10 #include <stdio.h> void demoFunction1(int value); int main(void) { int n=10; } printf("Before calling demo function: n --> %i\n", n); demoFunction1(n); printf("After calling demo function: n --> %i\n",n); return 0; void demoFunction1(int value) { printf("Inside demo function: value --> %i\n", value); value= 999; printf("Inside demo function: value --> %i\n", value); }
BefoBefore calling demo function: n --> 10 Inside demo function: value --> 10 Inside demo function: value --> 999 After calling demo function: n --> 10 re calling demo function: n --> 10 Inside demo function: value --> 10 Inside demo function: value --> 999 After calling demo function: n --> 10 Write a C program that creates two 1-dimension arrays of integer values, copies the values of these arrays in a third array, and print the values of all of them on the screen by using functions #include <stdio.h> #define SIZE_1 5 #define SIZE_2 3 printf("Enter array 1 values: \n"); readArray(v1, SIZE_1); printf("Enter array 2 values: \n"); readArray(v2, SIZE_2); copyArrays(v1, v2, v3, SIZE_1, SIZE_2); printf("Array values: \n"); printArray(v1, SIZE_1); printArray(v2, SIZE_2); printArray(v3, SIZE_1 + SIZE_2); return 0; }
void readArray(int a[], int n) { int i; for (i=0; i<n; i++) scanf("%i", &a[i]); } void printArray(const int a[], int n) { int i; printf("[ "); for (i=0; i<n; i++)
printf ("%i ", a[i]); printf("] \n");