Ad Code

Responsive Advertisement

Ticker

6/recent/ticker-posts

C++ code to determine whether a number is negative or positive

 This code asks the user to enter an integer value, the program determines whether the number entered is negative or positive.

In the code an if else statement is used. A variable(number) is declared to hold the data entered by the user.

 If the condition “number<0” is true, the program displays “you have entered a negative number” but if the condition is false, the program displays “you have entered a positive number”.

 

When the above code is compiled and executed and 8 is entered the result displays


 


Post a Comment

0 Comments

Ad Code

Responsive Advertisement