Homework Solution: What is the arity of the conditional operator? ? Hint Recall, the arity of an operator is the number of operan…

    Very simple for someone who knows C++. Please answer all of them 12. (Continuing 10) What is the arity of the conditional operator? ? Hint Recall, the arity of an operator is the number of operands the operator requires. For example, the + operator requires 1 operand (a unary operator) and the % operator requires 2 operands (a binary operator). A: 0 B: 1 C: 2 D: 3 E: 4 13-14. Write a single nested if/else-statement (1) to display the string literal Zero and set y to3 when the integer x is equal to 0; (2) to display Negative and set y to 2 when x is less than 0; and (3) and to display Positive and set y to 1 when x is greater than 0. Hint Will you need to use blocks (compound statements)? 15-16. How many times will the body of the while-statement shown below execute? How many times will its boolean expression ( i <- 11) be evaluated? generalization about the relationship of these 2 counts which holds for all while-statements. times times. Make a while Li <- 11) 17-18. write a while-statement to determine the largest value of n such that 0+1+2+···+n Assume the pre-condition ((x >= 0) && (n >= 0)) is satisfied. 19. Express both sets of answers using powers of 2. What range of integer values does the 32-bit unsigned int C/C++ data type represent? <-x. Hint whole numbers) What range of integer values does the 32-bit signed int C/C++ data type represent? (Hint integers) 20. (Continuing 19) Adding 1 to the upper-bound of the unsigned ove int range will cause integer to occur 21. T or F? Un-initialized local variables contain RAM garbage (that is, contain undefined values). 22. The C/C++ data types float and double differ both in their dynamic range and in their of the floating-point (real) numbers they can represent. re
    What is the arity of the conditional operator? ? Hint Recall, the arity of an operator is the number of operands the operator requires. For example, the + operator requires 1 operand (a unary operator) and the % operator requires 2 operands (a binary operator). A: 0 B: 1 C: 2 D: 3 E: 4 Write a single nested if/else-statement (1) to display the string literal "Zero" and set y to3 when the integer x is equal to 0: (2) to display "Negative" and set y to 2 when x is less than 0: and (3) and to display "Positive" and set y to 1 when x is greater than 0. Hint Will you need to use blocks (compound statements)? How many times will the body of the while-statement shown below execute? How many times will its boolean expression (i = 0) && (n > = 0)) is satisfied. Express both sets of answers using powers of 2. What range of integer values does the 32-bit unsigned int C/C++ data type represent? What range of integer values does the 32-bit signed int C/C++ data type represent? Adding 1 to the upper-bound of the unsigned int range will cause integer ove _______ to occur. T or F? Un-initialized local variables contain "RAM garbage" (that is, contain undefined values). The C/C++ data types float and double differ both in their dynamic range and in their pre ________ of the floating-point (real) numbers they can represent.

    Expert Answer

     
    ANSWERS- 12. D=3 , ternary takes three operands.

    Very lowly control someone who knows C++. Please response total of them

    12. (Continuing 10) What is the arity of the liable operator? ? Hint Recall, the arity of an operator is the enumerate of operands the operator requires. Control specimen, the + operator requires 1 operand (a unary operator) and the % operator requires 2 operands (a binary operator). A: 0 B: 1 C: 2 D: 3 E: 4 13-14. Transcribe a only nested if/else-statement (1) to evidence the string verbal Zero and established y to3 when the integer x is similar to 0; (2) to evidence Negative and established y to 2 when x is hither than 0; and (3) and to evidence Positive and established y to 1 when x is elder than 0. Hint Succeed you insufficiency to right blocks (unification statements)? 15-16. How abundant times succeed the substance of the period-statement shown adown enact? How abundant times succeed its boolean indication ( i <- 11) be evaluated? generalization encircling the interconnection of these 2 counts which holds control total period-statements. times times. Make a period Li <- 11) 17-18. transcribe a period-statement to determine the largest rate of n such that 0+1+2+···+n Assume the predominant-requisite ((x >= 0) && (n >= 0)) is affable. 19. Express twain establisheds of responses using powers of 2. What place of integer rates does the 32-bit unattested int C/C++ grounds fashion dramatize? <-x. Hint well enumerates) What place of integer rates does the 32-bit attested int C/C++ grounds fashion dramatize? (Hint integers) 20. (Continuing 19) Adding 1 to the upper-bound of the unattested ove int place succeed caright integer to supervene 21. T or F? Un-initialized national fickles comprehend RAM offal (that is, comprehend monstrous rates). 22. The C/C++ grounds fashions bear and embrace disagree twain in their dynamic place and in their of the bearing-point (real) enumerates they can dramatize. re

    What is the arity of the liable operator? ? Hint Recall, the arity of an operator is the enumerate of operands the operator requires. Control specimen, the + operator requires 1 operand (a unary operator) and the % operator requires 2 operands (a binary operator). A: 0 B: 1 C: 2 D: 3 E: 4 Transcribe a only nested if/else-statement (1) to evidence the string verbal “Zero” and established y to3 when the integer x is similar to 0: (2) to evidence “Negative” and established y to 2 when x is hither than 0: and (3) and to evidence “Positive” and established y to 1 when x is elder than 0. Hint Succeed you insufficiency to right blocks (unification statements)? How abundant times succeed the substance of the period-statement shown adown enact? How abundant times succeed its boolean indication (i = 0) && (n > = 0)) is affable. Express twain establisheds of responses using powers of 2. What place of integer rates does the 32-bit unattested int C/C++ grounds fashion dramatize? What place of integer rates does the 32-bit attested int C/C++ grounds fashion dramatize? Adding 1 to the upper-bound of the unattested int place succeed caright integer ove _______ to supervene. T or F? Un-initialized national fickles comprehend “RAM offal” (that is, comprehend monstrous rates). The C/C++ grounds fashions bear and embrace disagree twain in their dynamic place and in their predominantdominant ________ of the bearing-point (real) enumerates they can dramatize.

    Expert Response

     

    ANSWERS-

    12. D=3 , ternary takes three operands.
    13-14.
    if(x==0)
    {
    cout<< “zero”;
    y=3;
    }
    else if(x<0)
    {
    cout<<“Negative”;
    y=2;
    }
    else
    {
    cout<<“Positive”;
    y=1;
    }
    There is a insufficiency to right unification statements.

    15-16.

    1.i=1, loop exexutes
    2.i=3, loop enacts
    3.i=5, loop enacts
    4.i=7, loop enacts
    5.i=9, loop enacts
    6.i=11, loop enacts
    7.i=13, loop deterrent is terminated.

    The loop enacts 6 times and the loop requisite is checked 7 times.

    Generalization
    Count(loop condtion)=1+ Count(Loop deterrent)

    17-18.
    int sum=0;
    while(n>=0 && x>=0)
    {
    sum+=n;
    if(sum>x)
    break;

    n=n-1;
    }

    19. a] 0, 2^32-1
    b] 2^15, 2^15-1
    20. Overflow

    21. False, Uninitialized national fickle’s comportment is disagreeent from that of a fickle initialized with offal.

    22. predominantcision