Please help me writing this code in c++, I have no idea where to start!
Odd/Even: Find whether a number is odd or even (use mod operation).
a) Prompt user to enter a number (say, x).
b) Determine if x is an even/odd number and output an appropriate message.
c) Compute the squire of the number (say, x^2).
d) Determine if x^2 is an even or odd number and output an appropriate
message.
#include <iostream>
int main()
{
int x;
std::cout << "Enter number to determine if it's odd or even: ";
std::cin >> x;
std::cout << '\n';
if (x % 2 == 0)
{
std::cout << "This number is even\n";
}
else
{
std::cout << "This number is odd\n";
}
if (((x * x) % 2) == 0)
{
std::cout << "The square of this number is even\n";
}
else
{
std::cout << "The square of this number is odd\n";
}
std::cin.ignore(); // Pauses (optional)
return 0;
}