Question

In: Computer Science

Which expression can be used to check if an integer x is a multiple of 5...

Which expression can be used to check if an integer x is a multiple of 5 within the range 20 to 50 inclusively?

Select one:

a. (x >= 20 && x % 5 == 0) || (x <= 50 && x % 5 == 0)

b. x <= 50 && x >= 20 && x % 5 == 0

c. 20 <= (x % 5) <= 50

d. (x % 5 == 0) && (20 <= x <= 50)

Solutions

Expert Solution

Answer B is correct

x <= 50 && x >= 20 && x % 5 == 0

Explanation:

#include <iostream>
using namespace std;

int main()
{
    int x;
    cout<<"enter a number"<<endl;
    cin>>x;
    if(x <= 50 && x >= 20 && x % 5 == 0){
        // this expression is true for all multiple of 5
        cout<<"expression give true result"<<endl;
    }
    else{
        cout<<"expression give false result"<<endl;
    }

    return 0;
}

Option B :Answer option

Output:1 (for 15 it gives false result because it is less than 20)

Output 2:(for 25 it give true because it is a multiple of 5 and in a range of 20 and 50)

Option A:(x >= 20 && x % 5 == 0) || (x <= 50 && x % 5 == 0)(Wrong)

Proof:This expression give true for all values which give x%5==0

Opction C: 20 <= (x % 5) <= 50 (wrong)

Proof: This expression give true for all values of x

Option D: (x % 5 == 0) && (20 <= x <= 50) (Wrong)

Proof: This expression give true for all values which give x%5==0


Related Solutions

Prove that for any integer n the expression n7/7 + n5/5 + 23n/35 is whole integer....
Prove that for any integer n the expression n7/7 + n5/5 + 23n/35 is whole integer. (Hint: Note that the problem can be state in a following equivalent form: 35 | (5n7 +7n5 +23n); even further, by the previews theorem, it would be enough to show that (5n7 + 7n5 + 23n) is divisible by 5 and 7.)
Which of the following statements about RFID is/are not true? (MULTIPLE ANSWERS) A. Can be used...
Which of the following statements about RFID is/are not true? (MULTIPLE ANSWERS) A. Can be used in inventory management B. Tolltag is an RFID transmitter C. Sending device requires power to be applied in order to transmit. D. Requires a reader device which receives radio signals produced by a sending device E. Used to identify and display radio station and media playing on radio.
1. Which of the following can be treated as a Boolean expression? A. an int expression...
1. Which of the following can be treated as a Boolean expression? A. an int expression B. any of these C. the result of a comparison(such as <or>) D. a float expression 2. Assuming the variable x contains an integer value what will the result of the following statement be: if x<0 or x>=0. A. True B. False C. Sometimes true and sometimes false D. A "math domain" error will occur
Write a python function that accepts two integer values corresponding to the point (x, y). Check...
Write a python function that accepts two integer values corresponding to the point (x, y). Check whether the point is within the rectangle centered at (0, 0) with width 20 and height 15. For example, (-9, 7) is inside the rectangle and (11, 4) is outside the rectangle, as shown in the figure. Return True if the point falls within the rectangle and False otherwise
1. Which of the following is not a control to prevent check fraud? MULTIPLE CHOICE a....
1. Which of the following is not a control to prevent check fraud? MULTIPLE CHOICE a. Establish duties so the same person authorizes checks, signs them and reconciles the bank statement. b. Reconcile the bank account when you get the statement. c. Keep the check stock locked up. d. Perform background checks in the hiring process. 3. In a check tampering scheme the fraudster does not have to have physical access to the check. MULTIPLE CHOICE True or false 5....
Assembly Language Programming Exercise. Problem # 1: 1. Integer Expression Calculation( 5 pts ) Using the...
Assembly Language Programming Exercise. Problem # 1: 1. Integer Expression Calculation( 5 pts ) Using the AddTwo program from Section 3.2 as a reference, write a program that calculates the following expression, using registers: A = (A + B) − (C + D). Assign integer values to the EAX, EBX, ECX, and EDX registers.
Write a program to check given expression is valid or not.The expression consists of paranthsis like  [{(...
Write a program to check given expression is valid or not.The expression consists of paranthsis like  [{( if valid then convert into postfix expression and after conversion then evaluate postfix expession(using stack) and do not use build in stack. Use the c++ laguage.
Multiple Regression Analysis was used to find out which X variable have relationship with my Y...
Multiple Regression Analysis was used to find out which X variable have relationship with my Y variable (reduce overspending on food and beverage), and how strong relationship is.FIT A FIRST ORDER AUTO AGGRESSIVE MODEL (AR(1) USING Y(T) AS THE RESPONSE VARIABLE Y (T-1) AS THE INPUT VARIABLE. RECORD THE REGRESSION EQUATION. CALCULATE THE EXPONENTIAL SMOOTHING MODELS AND CALCULATE A MOVING AVERAGE MODEL. 4-Mar $31.69 5-Mar $4.19 5-Mar $19.01 5-Mar $7.99 6-Mar $3.32 6-Mar $57.11 7-Mar $4.07 8-Mar $2.49 8-Mar $6.30...
Which of the following methods should be used to check an athlete's responsiveness
1. Which of the following methods should be used to check an athlete's responsiveness?a. Slap the athlete's face while calling his name.b. Wiggle the athlete's foot.C. Tap or squeeze the athlete's shoulder and ask, Are you all right?d. Poke the athlete's arm or leg.e. Place smelling salts under the athlete's nose.2. While checking an athlete's breathing during the emergency action steps, you determine that the athlete is unable to speak and Is making gasping noises. First, you shoulda. ask, "Can...
Multiple tools can be used when determining which capital projects move forward, such as payback method,...
Multiple tools can be used when determining which capital projects move forward, such as payback method, accounting rate of return, and net present value. If capital resources are limited, which one of the approaches mentioned would you use to analyze a specific project and why? How would the cost of capital impact your decision? whether the identified method would be the best approach.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT