Questions 1-4 refer to the following program segment. Assume that all variables
ID: 3842213 • Letter: Q
Question
Questions 1-4 refer to the following program segment. Assume that all variables are of type int. z=0; g=0; s=0; i=0; while (i =0) g=g+1; else z=z+1; i=i+1;} How many times is the loop body of the while statement executed? a. once b. never c. 49 times d. 50 times e. until a number 50 or larger is entered The value stored in variable s at the end of the execution of the loop could best be described as ___. a. the average of the numbers scanned b. the sum of the numbers scanned c. the largest of the numbers scanned d. how many numbers were scanned e. the sentinel value The value stored in variable z at the end of the execution of the loop could best be described as ___. a. how many positive items were scanned b. the sum of all positive items scanned c. how many negative items were scanned d. the sum of all negative items scanned e. the sentinel valueExplanation / Answer
1) option d..the loop will be iterated for 50 times
2)option b....the sum of the numbers scanned
3)option a...how many positive numbers were scanned
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.