Advertisement
Guest User

7)

a guest
Apr 10th, 2020
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>
  2. /** 7) Hacer un programa para ingresar una lista de 10 números, luego informar cuántos son
  3. positivos, cuántos son negativos, y cuántos iguales a cero. **/
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int cv,pos=0, neg=0, cero=0, n, nverf;
  10.  
  11.     cout<< "ingrese la cantidad de numeros a verificar: ";
  12.     cin>>n;
  13.  
  14.     for(cv=1; cv<=n; cv++)
  15.     {
  16.         cout<< "ingrese el numero a verificar:";
  17.         cin>>nverf;
  18.         if(nverf>0)
  19.         {
  20.             pos++;
  21.         }
  22.         else
  23.         {
  24.             if(nverf<0)
  25.             {
  26.                 neg++;
  27.             }
  28.             else
  29.             {
  30.                 cero++;
  31.             }
  32.         }
  33.     }
  34.     cout<< "numeros positivos: "<< pos<< endl;
  35.     cout<< "numeros iguales a cero: "<< cero<<endl;
  36.     cout<< "numeros negativos: "<< neg<<endl;
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement