The constants 20 20 base 10 024 24 base 8 and 0 times 14 14

The constants 20 (20 base 10), 024 (24 base 8), and 0 times 14 (14 base 16) are equivalent and all have the same internal binary representation true false Given the code fragment int i, j; float r; i=3; d=4; r=5.0; r = i/j what is the final value of r 2.0 5.0 5.75 0.75 0.0 Given the code fragment int i, j; float r; i=3; j=4; r=5.0; r+= i/j what is the final value of r 2.0 5.0 5.75 0.75 0.0 It grade has the value of 50. what will the following code print? if (grade > 50) printf(\"Passed\"\'); nothing 50 Passed printf(\"Passed\") The conditional operator (?:) is a unary operator cannot be nested accepts two operands is the only ternary operative in C In a switch structure only one of the following is true: break; is required after each case ease value: value must be an integer constant default: is required break: is required after default: all of the above Given the following code fragment, what gets printed out? short i=2, 3=2, k=2; if (i == j && j == k) printf(\"All values are equal\"); else printf(\"The values are NOT equal\"); All values are equal The values are NOT equal nothing Which of the following will print correct if answer is equal to 4 and incorrect if (answer = 4) printf(answer ! = 4? \"correct\": \"incorrect\") printf (\"correct\"); printf(answer = 4 ? \"correct\": \"incorrect\") else answer = = 4 ? printf(\"correct\"): printf printf(\"incorrect\"); What is the value of y after executing the statement int y = 27 % 4; 31 6.75 3 274 6 Given the following code, what gets printed? ch = \'k\'; (ch = \'a\')printf(\"%c is lower-case alpha nothing c is lower-case alpha k is lower-case alpha

Solution

Question 41

In normal mathematics, we use generally base 10, binary is base 2, octal is base 8, hexa is base 16 . Here the number following base represents how many unique characters are used to represent any number in that base.

So 24 in base 8 = (2*(81 ) + 4*(80)) = 16 + 4 = 20.

Similarly 14 in base 16 = (1*(161 ) + 4*(160)) = 20.

So as all value turns out to be 20 . and so internal binary representation is same for all. so the Correct Answer is a) TRUE.

Question 42

This is because the expression i/j = 0 . This happens because i and j are integers and when we divide one integer with another integer the answer is integer rounded to its floor value (3/4 = 0.75 = 0 (floor value)).

So Correct Answer is e) 0.0

Question 43

Correct Answer is (b) 5.0. As explained in question 42 above i/j = 0 and expression (r+= i/j ) => evaluate i/j and add it to r . During addition 0 is upgraded to float value because of internal type conversion of compiler and answer is 5.0.

Question 44

Correct Answer is a) nothing . The if condition states that if the value of a is greater that 50 then print \"passed\" but as the value of a = 50. so if condition is false and hence Nothing is printed.

Question 45

Correct Answer is d) is the only ternary operator in C . Conditional operator ( first ? second : third ).

The first operator is automatically considered as bool, if the bool value is true then second is assigned as value else third is evaluated.

Question 46

Correct Answer is b) Case value must be an integer value . The other condition options are preferred way of writing switch statement but are not compulsory. So if you don\'t write default or if you don\'t end a case with break statement compiler won\'t raise any error, but if the case value is not integer compiler will raise the error.

Question 47

Correct Answer is a) All values are equal. i , j and k have qual values which is 2.

Question 48

Correct Answer D) answer == 4 ? printf (\"correct\") : printf(\"incorrect\")

Question 49

Correct Answer c) 3 . % operator is called modulo operator this gives reminder so 27 % 4 gives answer 3.

Question 50

Correct Answer c) K is lower-case alpha. %c is used to replace character

 The constants 20 (20 base 10), 024 (24 base 8), and 0 times 14 (14 base 16) are equivalent and all have the same internal binary representation true false Give
 The constants 20 (20 base 10), 024 (24 base 8), and 0 times 14 (14 base 16) are equivalent and all have the same internal binary representation true false Give

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site