Categoría de Estructura Condicional Anidada
💻 Hacer un programa donde se ingrese una hora determinada desde 1h a 24h y muestre si es de día de [6 hr a 12 hr], tarde desde [13 hr a 18 hr], noche de [19 hr a 24 hr] y madrugada de [1 hr a 5 hr].
Algoritmo programacion_work
// Muestra si es de día, tarde o noche.
Definir hora como Entero;
Escribir "INGRESE UNA HORA [1 - 24] : ";
Leer hora;
SI (hora >= 6 y hora <= 12) Entonces
Escribir "ES DE DÍA";
SiNo
SI (hora >= 13 y hora <= 18) Entonces
Escribir "ES DE TARDE";
SiNo
SI (hora >= 19 y hora <= 24) Entonces
Escribir "ES DE NOCHE";
SiNo
Escribir "ES DE MADRUGADA";
FinSi
FinSi
FinSi
FinAlgoritmo
print("MOSTRAR SI ES DE DÍA, TARDE, NOCHE O MADRUGADA")
hora = int(input("INGRESE UNA HORA [1 - 24] : "))
if hora >= 6 and hora <= 12:
print("ES DE DIA")
elif hora >= 13 and hora <= 18:
print("ES DE TARDE")
elif hora >= 19 and hora <= 24:
print("ES DE NOCHE")
else:
print("ES DE MADRUGADA")
#include<stdio.h>
int main() {
int hora;
printf("04. MOSTRAR SI ES DE DIA, TARDE, NOCHE O MADRUGADA.\n\n");
printf("INGRESE UNA HORA [1 - 24] : ");
scanf("%d",&hora);
if(hora >= 6 && hora <= 12){
printf("\nES DE DIA");
}else{
if(hora >= 13 && hora <= 18){
printf("\nES DE TARDE");
}else{
if(hora >= 19 && hora <= 24){
printf("\nES DE NOCHE");
}else{
printf("\nES DE MADRUGADA");
}
}
}
return 0;
}
#include<iostream>
using namespace std;
int main() {
int hora;
cout << "04. MOSTRAR SI ES DE DIA, TARDE, NOCHE O MADRUGADA." << endl;
cout << "INGRESE UNA HORA [1 - 24] : ";
cin >> hora;
if(hora >= 6 && hora <= 12){
cout << "ES DE DIA" << endl;
}else{
if(hora >= 13 && hora <= 18){
cout << "ES DE TARDE" << endl;
}else{
if(hora >= 19 && hora <= 24){
cout << "ES DE NOCHE" << endl;
}else{
cout << "ES DE MADRUGADA" << endl;
}
}
}
return 0;
}
package programacion_work;
import java.util.Scanner;
public class dia_tarde_noche_madrugada {
public static void main(String[] args) {
int hora;
Scanner ingreso=new Scanner(System.in);
System.out.print("INGRESE UNA HORA [1 - 24] : ");
hora = Integer.parseInt(ingreso.next());
if(hora >= 6 && hora <= 12){
System.out.println("ES DE DIA");
}else{
if(hora >= 13 && hora <= 18){
System.out.println("ES DE TARDE");
}else{
if(hora >= 19 && hora <= 24){
System.out.println("ES DE NOCHE");
}else{
System.out.println("ES DE MADRUGADA");
}
}
}
}
}