30.5k views
5 votes
A conditional expression is to be written in a programming language to determine whether a given number is negative or positive. Which of the following options represents the correct conditional expression for this task?

A) print(num >= 0)
B) print(num < 0)
C) print(num == 0)
D) print(num > 0)

User RGil
by
7.9k points

1 Answer

3 votes

Final answer:

The correct conditional expression to determine if a number is negative or positive is 'print(num < 0)'.

Step-by-step explanation:

The correct conditional expression to determine whether a given number is negative or positive is option B) print(num < 0). This expression checks if the value of 'num' is less than 0. If it is, then the number is considered negative; otherwise, it is positive or zero. Option A) checks if the value is greater than or equal to 0, option C) checks if the value is equal to 0, and option D) checks if the value is greater than 0.

User Iamsujit
by
8.4k points