sample

Here we are writing a C and C++ Program to Check whether the number entered by the user is a Positive Number or a Negative Number or Zero.

First we ask the user to enter a number and then we store it in a variable.Then we use the if else conditional statement to check the number and display the result.

Program Source Code : check_number.c

1 #Variable for Storing the distance in Kilometers
2 km = 10
3 
4 #Calculating the Distance in Miles
5 miles = km * 0.621371
6 
7 #Printing the Result
8 print('%.2f Kilometer = %0.2f Miles' %(km, miles))

Program Output

Enter an operator (+, -, *, /) : +
Enter two operands: 10 20
10.0 + 20.0 = 30.0

Video Tutorial : C Program to Check for Positive Negative Number or zero

Program Source Code : check_numnber.cpp

1 #Variable for Storing the distance in Kilometers
2 km = 10
3 
4 #Calculating the Distance in Miles
5 miles = km * 0.621371
6 
7 #Printing the Result
8 print('%.2f Kilometer = %0.2f Miles' %(km, miles))

C++ Program to Check for Positive Negative Number or zero