How do I start writing this program help!

closed account (4wRjE3v7)
Hi I need to write this but have no idea where to start, I am new to c++. Any tips and help are greatly appreciated.

Write a C++ program that asks the user to enter a number and outputs a message indicating whether the number is even, odd or zero.

Ex:

Please enter a number: 17
You entered an odd number


PS
What have you done so far?
Start by writing int main(). Then get pencil and paper and write down exactly what you want to do then starting at the first line, tell the computer exactly how you want to do what you wrote down
// Enter libraries
using namespace std; //Just do this

int main(int nNumberofArgs, char* pszArgs[]) //int main()
{
int // declare your variables
int

cout << "Enter a number..." // prompt user
cin >> // store input
cout << endl; // For looks

if(input == 0)
{
//if input == 0
}
if(input < 0)
{
// what would you do if it was a negative
}
test = input _ 2; // fill in the blank, how would you test this number?

switch(...) // test your variable
{
case ?:
// If this happens, what happens next?
system("PAUSE"); //Pause program
return 0; // end program
default: //if different from all other cases
// what now?
system("PAUSE");
return 0;
}
}
1. declare a variable "num"
2. if num = 0 then....
3. if num = odd then ...
4. if num = even then ...







#include <iostream>
using namespace std;
int main()
{
int num;
cout << "Please enter a number: ";
cin >> num;
if (num==0)
cout << "You entered a zero.";
else if (num%2==0)
cout << "You entered an even number.";
else
cout << "You entered an odd number.";
}
LOLs
Topic archived. No new replies allowed.