Ask Question
20 January, 17:26

Given the following expressions, what value would they have in a C+ + program?

a. 13 / 4

b. 2 + 12 / 4

c. 21 % 5

d. 3 - 5 % 7

e. 17.0 / 4

f. 8 - 5 * 2.0

g. 14 + 5 % 2 - 3

h. 15.0 + 3.0 / 2.0

+2
Answers (1)
  1. 20 January, 17:39
    0
    The program of the given expressions can be given as

    Program:

    #include

    using namespace std;

    int main () / /define main function.

    {

    float a, b, c, d, e, f, g, h; / /define variable for hold values.

    a=13 / 4;

    cout<<"a:"<
    b = 2 + 12 / 4;

    cout<<"b:"<
    c=21 % 5;

    cout<<"c:"<
    d=3 - 5 % 7;

    cout<<"d:"<
    e=17.0 / 4;

    cout<<"e:"<
    f=8 - 5 * 2.0;

    cout<<"f:"<
    g=4 + 5 % 2 - 3;

    cout<<"g:"<
    h=15.0 + 3.0 / 2.0;

    cout<<"h:"<
    return 0;

    }

    output:

    a=3.

    b=5.

    c=1.

    d=-2.

    e=4.25.

    f=-2.

    g=2.

    h=16.5.

    Explanation:

    In the above expression, all the options follow the bodmos rules. All the expression explanation can be given as:

    In option (a) we divide the value. It gives the quotient.

    In option (b) we first divide the value and then addition.

    In option (c) we Modulus the value. It gives the remainder.

    In option (d) we first Modulus the value and then Subtract It.

    In option (e) we divide the value. It gives the quotient.

    In option (f) we first multiply the value and then Subtract It.

    In option (g) we first Modulus the value, second addition than subtraction.

    In option (h) we first divide the value and then addition.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Given the following expressions, what value would they have in a C+ + program? a. 13 / 4 b. 2 + 12 / 4 c. 21 % 5 d. 3 - 5 % 7 e. 17.0 / 4 ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers