Decir si son negativos o positivos

Página 120 ejercicio 1

// Decir si son positivos o negativos.
#include <iostream>
#include <cmath>
using namespace std;

int main ()
{
int n1, n2;
cout << "Escribe un numero: ";
cin >> n1;
cout << "Escribe otro numero: ";
cin >> n2;
if ((n1 < 0) && (n2 < 0))
cout << n1 << " y " << n2 << " son numeros negativos";
if ((n1 >= 0) && (n2 >= 0))
cout << n1 << " y " << n2 << " son numeros positivos";
if ((n1 < 0) && (n2 >= 0))
cout << n1 << " es un numero negativo y " << n2 << " es un numero positivo.";
if ((n1 >= 0) && (n2 < 0))
cout << n1 << " es un numero positivo y " << n2 << " es un numero negativo.";
return 0;
}






No hay comentarios:

Publicar un comentario