Answer:
b
Explanation:
they say this on the quiz but because of the irrationality DNA has
Answer:
Option d num = 50, min = 50, max = 50
Explanation:
Given the code segment:
- boolean isBigger;
- boolean isSmaller;
- boolean inRange;
- if (num < max)
- {
- isSmaller = true;
- }
- else {
- isSmaller = false;
- }
-
- if (num > min)
- {
- isBigger = true;
- }
- else {
- isBigger = false;
- }
-
- if (isBigger == isSmaller) {
- inRange = true;
- } else {
- inRange = false;
- }
If we have num = 50, min = 50 , max = 50, the condition num < max will be evaluated to false and therefore isSmaller is set to false.
The condition num > min will be evaluated to false as well and therefore isBigger is set to false.
Since isSmaller and isBigger are both false and therefore isBigger == isSmaller will be evaluated to true and set the inRange = true. This has violated the statement that if the integer value num is greater than min value and less than max value, then only set inRange to true. This is because num = 50 is neither greater than min nor less than max, it is supposedly not in range according to the original intention of the code design.
Answer:
The algorithm is as follows:
Input number
count = 0
while(number not equal 0)
number = number / 10
count = count + 1
end
Print count
Explanation:
This gets input for the integer number
Input number
This initializes count of digits to 0
count = 0
The following loop is repeated while number is not 0
while(number not equal 0)
This performs integer division of the number by 10; the resulting division is saved in variable number
number = number / 10
The count variable is incremented by 1
count = count + 1
The loop ends here
end
This prints the count of integers
Print count
<em>See attachment for flowchart</em>