Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int idEmpleados [100] = {0};
- int idEmpleadosPrimos [100] = {0};
- char mander = 's';
- int validos = 0;
- int valor = 1;
- int suma = 0;
- int limite = 5;
- while (validos < limite)
- {
- idEmpleados[validos] = valor;
- valor++;
- validos++;
- }
- for (int i=0;i<validos;i++)
- {
- printf("%d arreglo[%d] --> %d\n",i,i+1,idEmpleados[i]);
- }
- /*
- Dado un el vector {1,5,6,7,8} escribir un programa
- que genere otro vector con
- la suma del contenido de todo los elementos anteriores al índice actual: {1,6,12,19,27}.
- */
- idEmpleadosPrimos[0] = idEmpleados[0];
- for (int i=1;i<validos;i++)
- {
- idEmpleadosPrimos[i] = idEmpleadosPrimos[i-1] +idEmpleados[i];
- }
- printf("\n");
- for (int i=0;i<validos;i++)
- {
- printf("%d arreglo[%d] --> %d\n",i,i+1,idEmpleadosPrimos[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment