• Lenguaje

    Pascal

  • Descripción

    Usando "Para" y "Si entonces" permita ingresar 10 números, sume los positivos y cuente los negativos. Esto sólo usando solo 4 variables.

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
program SumaDePositivosYCuentaDeNegativos;
uses crt;

var cuenta_negativos, i, suma_positivos, un_numero : integer;
begin
    cuenta_negativos := 0;
    suma_positivos := 0;
    for i:=1 to 10 do
    begin
        writeln ('PROCESO ', i);
        write ('Ingresa el valor de un numero: ');
        readln (un_numero);
        if un_numero>0 then
            begin
                suma_positivos := suma_positivos+un_numero;
            end;
        if un_numero<0 then
            begin
                cuenta_negativos := cuenta_negativos+1;
            end;
        writeln;
    end;
    writeln ('Valor de cuenta negativos: ', cuenta_negativos);
    writeln ('Valor de suma positivos: ', suma_positivos);
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.