Categoría de Estructura Condicional Simple
💻 Hacer un programa dónde se ingrese un número entero y muestre si es un número positivo o negativo, considerar 0 como positivo.
Algoritmo programacion_work
Definir num como Entero;
Escribir "06. MUESTRA NÚMERO POSITIVO O NEGATIVO";
Escribir Sin Saltar "INGRESE NÚMERO : ";
Leer num;
Escribir "";
Si (num >= 0) Entonces
Escribir "NÚMERO POSITIVO";
SiNo
Escribir "NÚMERO NEGATIVO";
FinSi
FinAlgoritmo
print("06. MUESTRA NÚMERO POSITIVO o NEGATIVO")
num = int(input("INGRESE CANTIDAD : "))
if num >= 0:
print("NÚMERO POSITIVO")
else:
print("NÚMERO NEGATIVO")
#include<stdio.h>
int main() {
int num;
printf("06. MUESTRA SI ES UN NUMERO POSITIVO O NEGATIVO.\n\n");
printf("INGRESE NUMERO : ");
scanf("%d",&num);
if(num >= 0){
printf("\nNUMERO POSITIVO");
}else{
printf("\nNUMERO NEGATIVO");
}
return 0;
}
#include<iostream>
using namespace std;
int main() {
int num;
cout << "06. MUESTRA SI ES UN NÚMERO POSITIVO O NEGATIVO.\n\n";
cout << "INGRESE NUMERO : ";
cin << num;
cout << endl;
if(num >= 0){
cout << "NUMERO POSITIVO" << endl;
}else{
cout << "NUMERO NEGATIVO" << endl;
}
return 0;
}
package programacion_work;
import java.util.Scanner;
public class positivo_negativo {
public static void main(String[] args) {
// MUESTRA NÚMERO POSITIVO O NEGATIVO
int num;
Scanner ingreso=new Scanner(System.in);
System.out.print("INGRESE NUMERO : ");
num = Integer.parseInt(ingreso.next());
if(num >= 0){
System.out.println("NUMERO POSITIVO");
}else{
System.out.println("NUMERO NEGATIVO");
}
}
}