Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

28. What is the final value of the following program segment? double result resu

ID: 3600033 • Letter: 2

Question

28. What is the final value of the following program segment? double result result = 4-23963 ; 29. (3 pts) What are the values of the following logical conditions siven: A-o 8-1 01 30. x=1.6 Y-8.6 K-10 True or false Y-K>X? 31, A CONTINUE statement is used to skip a statement in a loop 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 vailues 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(2), play For ( play-0xplayc4; play*+) moon moon-play; cout

Explanation / Answer

28)
Given program segment is
double result;
result = 4-23%3; // result stores 2.000000 in it.

Explanation

result variable stores the value 2.000000 as its return type is double. Expresion calculates 23%3 = 2 because when 23 divided by 3 leaves the remainder 2 and then 2 is substracted from "4" i.e,4-2 gives "2.000000" and stores in the result variable.

29)
Given, A=0,B=1 and C=1
a) (A&&B)||(B&&C) ----> (0&&1)||(1&&1) --> 0 || 1 --> 1
b) (A&&B)&&(B&&C) ----> (0&&1)&&(1&&1) --> 0 && 1 --> 0
c) (A&&B)&&(B&&C)||(!C&&B) ----> (0&&1)&&(1&&1)||(0&&1) --> 0 && 1 || 0 --> 0

30) False
Given, X=1.6,Y=8.6 and K=10
Now, the condition Y-K = -1.4 and it is not greater than 1.6 i.e, value of X.So, it is false.

31) True --> CONTINUE statement used to go for next iteration and skip a statement in a loop.
32) Sentinel --> will terminate a loop by single special value.
33) for loop --> how many data values you were going to use is known than you need for loop to iterate.
34) moon=8play=4 --> Is displayed on screen as output
Given program segment is

int moon(2),play;
for(play=0;play<4;play++)
moon = moon+play;  
cout<<"moon="<<moon<<"play="<<play<<endl;

Explanation

If play =0 --> moon = 2+0=2 and increment value of play
If play =1 --> moon = 2+1=3 and increment value of play
If play =2 --> moon = 3+2=5 and increment value of play
If play =3 --> moon = 5+3=8 and increment value of play and at this point "moon" has value "8" in it.
If play =4 --> loop breaks and store play value as "4" by end of loop.

35) It executes "5" times (play=0 to 4) at 5th time the loop exits as play=4 (play<4 condition becomes false)
  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote