Answer to Question #280656 in C for Tharu

Question #280656

Project 3: Application of if statement


Requirements:

(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.


1
Expert's answer
2021-12-17T06:51:53-0500
#include <iostream>
using namespace std;


int main()
{
    int num;
    
    cout<<"Enter a Number: ";
    cin>>num;
    
    if (num > 0)
    {
        cout<<"z"<<endl;
        if (num % 2 == 0)
        {
            cout<<"o"<<endl;
        }
        else
        {
            cout<<"j"<<endl;
        }
    }
    else
    {
        cout<<"f"<<endl;
        if (num % 2 == 0)
        {
            cout<<"o"<<endl;
        }
        else
        {
            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
APPROVED BY CLIENTS