28. What is the final value of the following program segment? double result resu
ID: 3738694 • Letter: 2
Question
28. What is the final value of the following program segment? double result results 4-25563 ; 29. (3 pts) what are the values of the following logical conditions given: A 1 B 1 CO a. (A&&B;)11( B&& C) 30. X-1.5 Y-8.6 K-10 True or false Y-K>X? 31. A CONTINUE statement is used to immediately exit from a loop T or F 32. Which loop implementation will terminate a loop by a single special value being entered but not due to running out of data ? a end-of-data b. sentinel c. counter-controlled d. for loop 33. what technique to end a loop would you use if you knew in advance how many data values you were going to use but not due to running out of data? a. end-of-data b. sentinel c. counter- controlled d. for loop Given this program setment Int moon(0), play; For ( play 0:playExplanation / Answer
Please find the answers below :
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Ques 28 : The result of the operation will cause an compile time error as the values are on the left and right side are double and int.
and the operator is binary operator which does not apply to them
Here, result = 4.25 % 3
4.25 => is double number.
3 => int number.
% => is the binary modulus operator.
hence it will give error.
Ques 29 :
a (A&&B)||(B&&C)
This statement will return true as the first condition (A&&B) is true, where as the second statement (B&&C) is false.
Since it is '||' statement, it will be considered true because the OR operator needs any of its conditions to be true in order to get true as result.
b (A&&B)&&(B&&C)
This statement will return False as the first condition (A&&B) is true, where as the second statement (B&&C) is false.
Since it is '&&' statement, it will be considered false because the AND operator needs all its conditions to be true in order to get true as result.
c (A&&B)&&(B&&C)||(!C&&B)
This statement will return true,as the first condition (A&&B) is true, where as the second statement (B&&C) is false, the third statement is also true.
But since it is complex expression but the overall result will be evaluated in order of left ot right, so the result of true && false || true will be true,
since (A&&B) is true, (B&&C) is false and (!C&&B) is also true.
Ques 30.
the condition y-k > x will result false, as the values are
x = 1.5 ,
y = 8.6,
k = 10.
so the result of y-k = -1.4.
which is less than x having value 1.5.
Hence the answer is false.
Ques 31.
The continue statement is used to continue over that iteration within the loop.
Alter that the program pointer again goes to the condition to check whether it satisfies the condition or not.
for eg, consider the following code snippet.
for(int a = 0; a<=10;a++){
if(a==5){
continue;
}
print(a);
}
Here, in the above code the loop will run 10 times in this when a is 5, continue statement will execute that will cause the pointer to go and check the loop again with updated data.
So the answer is false.
Ques 32.
The answer is Sentianl loop.
Here there are 2 types of loops
1. Entry controlled loop - Counter Control Loop
2. Exit controlled loop - Sentinal Control Loop.
In Counter Control loops, the entry point and end of data is predefined, the loop must go that many times.
In Sentinal control loops, the entry point is defined but the exit point is not predefied, it is calculated dynamically or it can even to till infinity.
Ques 33.
If we know in advance the number of times it should iterate, then its better to use counter control loop.
But the requirement which we are having also states that the loop should not end with end of data.
Hence here, in this case we have to use Sentinal loop. Once example of Sentinal Loop is While loop.
Ques 34.
The output is moon = 6 play = 4 .
The moon is sum of 1 + 2 + 3 and play's final value is 4.
Ques 35.
The loop ran for 4 times
i.e. for play =0
play = 1,
play =2,
play =3
When the value of play incremented to 4, the loop terminated.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.