• Lenguaje

    C

  • Descripción

    Leer 20 números mostrar cuantos son positivos, cuantos negativos y cuantos neutros.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    int i, negativos, neutros, positivos;
    float un_numero;
    negativos = 0;
    neutros = 0;
    positivos = 0;
    for (i=1; i<=20; i++)
    {
        printf ("PROCESO %d\n", i);
        printf ("Ingresa el valor de un numero: ");
        scanf ("%f", &un_numero);
        (void) getchar ();
        if(un_numero<0)
            negativos=negativos+1;
        if(un_numero==0)
            neutros=neutros+1;
        if(un_numero>0)
            positivos=positivos+1;
        putchar ('\n');
    }
    printf ("Valor de negativos: %d\n", negativos);
    printf ("Valor de neutros: %d\n", neutros);
    printf ("Valor de positivos: %d\n", positivos);
    system ("pause");
    return EXIT_SUCCESS;
}