Answer to Question #277985 in C++ for Roe

Question #277985

Write c++ code that

(1) Please program to judge the positive and negative and odd and even of an input integer.

(2) If it is a positive number, please output z; if it is a negative number, please output f.

(3) If it is an even number, please output o; if it is an odd number, please output j.

(4)test run the code


1
Expert's answer
2021-12-10T06:38:31-0500
#include <iostream>

using namespace std;

int main() 
{
  double number;
  cin >> number;
  if (number < 0) // negative number
    cout << 'z' << endl;
  if (number > 0) // positive number
    cout << 'f' << endl;
  if (number % 2 == 0) // even number
    cout << 'o' << endl;
  if (number % 2 == 1) // odd number
    cout << 'j' << endl;
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog