Respuesta :
Answer:
Following is the program in C++ Language
#include <iostream> // header file
using namespace std; // namespace std
int main() // main method
{
int n; // variable declaration
cout<<" Please enter the number :";
cin>>n; // Read the number
if(n>0) // check the condition when number is positive
{
cout<<n<<endl<<"The number is Positive"; // Display number
}
else if(n<0) // check the condition when number is Negative
{
cout<<n<<endl<<"The number is Negative";// Display number
}
else // check the condition when number is Zero
{
cout<<n<<endl<<"The number is Zero";// Display number
}
return 0;
}
Output:
Please enter the number:
64
The number is Positive
Explanation:
Following are the description of the program
- Declared a variable "n" of int type.
- Read the value of "n" by user.
- Check the condition of positive number by using if block statement .If n>0 it print the number is positive.
- Check the condition of negative number by using else if block statement If n<0 it print the number is negative.
- Finally if both the above condition is fail it print the message " The number is Zero"
Following are the program to the given question:
Program Explanation:
- Defining header file.
- Declaring an integer variable "x" that inputs the integer value from the user-end.
- After the input value, the "if-else-if Ladder is used that checks the input value.
- In the, if block it checks x value greater than 0, it prints the positive value with the message.
- In the else if block, it checks x value less than 0, it prints the negative value with the message.
- In the next else if block, it checks x value equal to 0, it prints the zero value with the message.
- In the else block, it prints the wrong input value as a message.
Program:
#include // header file
using namespace std;
int main() // main method
{
int x; // declaring the integer variable
cout<<"Enter the number: ";//print message
cin>>x; // input integer value
if(x>0) // checking the condition of the given number that is positive
{
cout<
}
else if(x<0) // checking the condition of the given number that is negative
{
cout<
}
else if (x==0) // check the condition when number is Zero
{
cout<
}
else
{
cout<<"wrong input";// print message
}
return 0;
}
Output:
Please find the attached file.
Learn more:
brainly.com/question/13168905

