Question

this is written in c++

This code needs to work with any input to have the output with different numbers that are entered in.

Please help me I need help with this problem.

Thanks


$ Section 4.4 is a part of assignment Lab21: Number Divisible by 4 and/or 5 Requirements: zylab Entire class due: 03/01/2020,

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;

    if (n % 4 == 0 && n % 5 == 0) {
        cout << n << " is divisible by both 4 and 5." << endl;
    } else if (n % 4 == 0 || n % 5 == 0) {
        cout << n << " is divisible by either 4 or 5, but not both." << endl;
    } else {
        cout << n << " is divisible by neither 4 nor 5." << endl;
    }
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
this is written in c++ This code needs to work with any input to have the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This exercise is also from C++ How do I even figure this out? please help me...

    This exercise is also from C++ How do I even figure this out? please help me solve so I can get the answer correctly! Question 28 10 pts (SHORT ANSWER) Define a function named findEvenOrOdd that has 1 int parameter: num. When the function is called, it should use an if/else statement -OR- conditional expression to determine whether the variable num is an even or odd number and display appropriate message as follows: • If the value in num is...

  • Write a program that will accept an integer as input from the user and test if...

    Write a program that will accept an integer as input from the user and test if that input is an even number. It should also test if the input is evenly divisible by 6. The program should display “Even” if the user’s input is even. It should additionally display “divisible by 6” if the user’s input is evenly divisible by six. #include <iostream> using namespace std; int main(){      return 0; } Convert the following switch statement to an if-...

  • Code in C An integer is divisible by 9 if the sum of its digits is...

    Code in C An integer is divisible by 9 if the sum of its digits is divisibleExample output: by 9. Develop a program which will call UDF: int get input(); to prompt the user for an integer and return this user input to main() Call UDF: Enter an integer: 5463 3 4 5 5463 is divisible by 9 void display int val); to display each digit of the integer starting with the rightmost digit. Your program should also determine whether...

  • python programming X Canvas 4 → XCO Question 26 10 pts (SHORT ANSWER) Define a function...

    python programming X Canvas 4 → XCO Question 26 10 pts (SHORT ANSWER) Define a function named find_even_odd that has 1 parameter: num. When the function is called, it should use an if/else statement to determine whether the variable num is an even or odd number and display appropriate message as follows: • If the value in num is an even number, the progr will output the message: "XX is an EVEN number", where XX is the value in the...

  • c++ assignment about command line

    Write a program that uses command-line processing to get a number of integers and then print them out in descending order. The number of input integers is limited to 5 ; otherwise, an error message should be displayed. A sample output is shown below:I still cant figure out how to do the c++ command line assignment on visual studios so help me with the full coding asap.Keep in mind the program should be a beginner's level and dont make it...

  • PLEASE WRITE CODE FOR C++ ! Time Validation, Leap Year and Money Growth PartA: Validate Day and Time Write a program tha...

    PLEASE WRITE CODE FOR C++ ! Time Validation, Leap Year and Money Growth PartA: Validate Day and Time Write a program that reads a values for hour and minute from the input test file timeData.txt . The data read for valid hour and valid minute entries. Assume you are working with a 24 hour time format. Your program should use functions called validateHour and validateMinutes. Below is a sample of the format to use for your output file  timeValidation.txt :   ...

  • Modify your code from the previous part so that once the customer finishes selection from the...

    Modify your code from the previous part so that once the customer finishes selection from the menu and sees the receipt, they are presented with one final menu. This menu should allow the customer to select the pay options. Their choices should be: (a) Cash (b) One time pay card Again, the user should make their selection by entering the corresponding number, and bad selections should cause the menu to repeat. If customer chooses ‘Cash’ it should print that payment...

  • Write an interactive C++ program that asks a user to input the color code of a...

    Write an interactive C++ program that asks a user to input the color code of a resistor and determines its value and tolerance Tell the user how to input the color rings “Instructions” Tell the user to input the colors one after the other After the program receives the information it will display the resistance and tolerance Output an error message if the user enters an invalid color code (no garbage values should be displayed), and ask for another input...

  • this should be a code for C++ the source code file so the program will operate...

    this should be a code for C++ the source code file so the program will operate as described below. These are the software requirements for the project. When the program runs, it shall display the text as shown on lines 1-11 in the example below. Next, it shall display a prompt message asking the user to enter his or her yearly salary. Next, it shall shall read the user's salary from the keyboard (in the example below, user input is...

  • C++ requirements The store number must be of type unsigned int. The sales value must be...

    C++ requirements The store number must be of type unsigned int. The sales value must be of of type long long int. Your program must properly check for end of file. See the section Reading in files below and also see your Gaddis text book for details on reading in file and checking for end of file. Your program must properly open and close all files. Failure to follow the C++ requirements could reduce the points received from passing the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT