gonzalob

Untitled

Apr 16th, 2020
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.02 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "../pila.h"
  4.  
  5.  
  6. int main()
  7. {
  8.     int idEmpleados [100] = {0};
  9.     char mander = 's';
  10.     int validos = 0;
  11.     int valor = 0;
  12.     int suma = 0;
  13.     int limite = 5;
  14.  
  15.     while ((mander == 's') && (validos < limite))
  16.     {
  17.         printf("ingrese un numero\n");
  18.         fflush(stdin);
  19.         scanf("%d",&valor);
  20.         idEmpleados[validos] = valor;
  21.         validos++;
  22.         printf("ingrese si desea seguir? s/n\n");
  23.         fflush(stdin);
  24.         scanf("%c",&mander);
  25.     }
  26.     for (int i=0;i<validos;i++)
  27.     {
  28.         printf("%d arreglo[%d] --> %d\n",i,i+1,idEmpleados[i]);
  29.     }
  30.     for (int i=0;i<validos;i++)
  31.     {
  32.         suma = suma + idEmpleados[i];
  33.     }
  34.     printf("la suma es %d",suma);
  35.    
  36.     idEmpleados[0] = 1; //ASIGNA
  37.     int menor = idEmpleados[0];//COPIA
  38.     for (int i=1;i<validos;i++)
  39.     {
  40.         if (menor > idEmpleados[i])
  41.         {
  42.              menor = idEmpleados[i];//COPIA
  43.         }
  44.     }
  45.     printf("el menor es %d",suma);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment