In the code segment below, assume that the int variable n has been properly declared and initialized. The code segment is intend
ed to print a value that is 1 more than twice the value of n. Missing code */ system. out. print(result); which of the following can be used to replace*/ missing code */ so that the code segment works as intended? a. int result = 2 * n; result = result + 1.
b. int result = n + 1; result = result * 2.
c. int result = (n + 1) * 2.
Option a is the correct answer for the above question.
Explanation:
The question wants the output of "one more than the double of n".It is also called as "2n+1".Then the value of n will be multiplied by 2 and then 1 will be added on it.
It is formed by the option 'a' which have two statements. The first statement multiplies the value of n by 2 and stores it into result and the value becomes twice of n and then the second statement adds the 1 value to the result value and again store the value in the result. So the result variable stores the (2*n) +1 value. Hence Option a is correct while the other is not because--
Option b gives the result value as "2(n+1)", which can be 2*n+2.
Option c gives the result value as same as the option b.
In Oracle11 g ORDER BY clause is used to sort data andit is also used in mysql ,ms access.Though we not to mention ASC to sort in increasing order because by default it sorts the data in ascending order if we do not mention ASC or DESC.To sort in descending order we have to mention DESC.