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.";
}