Ask Question
16 August, 11:16

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

+5
Answers (1)
  1. 16 August, 12:35
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers