how to write

How to Write a program that prompts the user to input a number. The program should then output the number and a message saying whether the number is positive, negative, or zero.
Save as Number.cpp

Last edited on
can anyone help me
Which aspect, specifically, are you having trouble with?

Also, you waited 2 whole minutes before bumping your thread? Seriously? You need to be more patient. You're very unlikely to get an immediate answer to anything here. People come here in their spare time, and answer threads as and when they choose.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>

using namespace std;

int main ()
{
  int number = 0;

  cout << "Enter a number: ";
  cin >> number;
  if (number == 0)
    cout << "Number is zero";
  else if (number < 0)
    cout << "Number is less than zero";
  else
    cout << "Number is greater than zero";
  return 0;
}
Topic archived. No new replies allowed.