Está en la página 1de 2

Universidad Militar Nueva Granada

Facultad de Ingeniería – Programa Ingeniería


Visual C++
Ejemplo Estructura Selectiva Anidada

Alcira Ordóñez Rey

Problema: Leer una nota y validar que se encuentre fuera del rango de 0.0 a 5.0 (Usar
el operador lógico O - ||)

Código:

/* Leer un número ingresado por teclado y verificar si es:


- neutro
- par positivo
- par negativo
- impar positivo
- impar negativo

Entrada numero int


Proceso
Salida */
#include <iostream>
using namespace std;
int main()
{
int numero;
cout << "Numero: ";
cin >> numero;

if (numero == 0)
{
cout << "El numero es CERO" << endl;
}
else
{
if (numero > 0)
{
if (numero % 2 == 0)
{
cout << "El numero es PAR POSITIVO" << endl;
}
else
{
cout << "El numero es IMPAR POSITIVO" << endl;
}
}
else
{
if (numero % 2 == 0)
{
cout << "El numero es PAR NEGATIVO" << endl;
}
else
{
cout << "El numero es IMPAR NEGATIVO" << endl;
}
}
}
system("pause");
return 0;
}

Salida por consola

También podría gustarte