plzz give me the ans of this question
Answers
Hi,
You haven't specified any language, so I'm assuming that question is related to javascript.
const num = parseInt(prompt("Enter number to check if it's positive or not"));
if (num > 0) {
alert(num + " is a positive number");
} else {
alert(num + " is a negative number");
}
in first line we are taking input from user using prompt() function then we are converting that input from string to number because prompt returns string.
in second line we are if number is greater than 0 or not if it is, that means number is positive, so we are showing an alert message to user which says that number is positive in third line.
if num > 0 is not true that means number is negative so there is no need to check if number is less than zero or not, so we are showing an alert message to user which says that number is negative.