Computer Science, asked by rakhi1215, 5 months ago

Write aprogram to check whether a number is positive, negative or zero using if else statement​

Answers

Answered by Anonymous
3

If you want to write a program in BlueJ then you have to use the following code:

import java.util.*;

public class check

{

public static void main(String args[])

{

int n;

Scanner sc=new Scanner (System.in);

System.out.println("Enter a number");

n=sc.nextInt();

if(n>0)

System.out.println("Positive number");

else if(n<0)

System.out.println("Negative number");

else

System.out.println("Zero");

}

}

If you are referring to Python then you have to use the following code:

num = float(input("Enter a number: "))

if num > 0:

print("Positive number")

elif num == 0:

print("Zero")

else:

print("Negative number")

Hope it helps. Please mark as brainliest.

Similar questions