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

must be in c++0 Which of the following is a repetition statement? a. if b. do ..

ID: 3866891 • Letter: M

Question


must be in c++0

Which of the following is a repetition statement? a. if b. do .. while. c. switch d. if .. else. If x initially contains the value 3, which of the following sets x to ? a. x + 4 = x: b. x =+ 4: c. x += 4: d. x ++ 4: Which of the following statements initializes the unsigned int variable counter to 10? a. unsigned int counter = 10: b. unsigned int counter = {10}: c. both a and b. d. none of the above. What is wrong with the following while loop? while (total 1000) { total = total - 20: } a. There should be a semicolon after while (total 1000). b. The parentheses should be braces. c. Do nothing the code is correct. d. Change total = total - 20 to total = total + 20 The data type bool for Boolean variables: a. Can only be used in a selection statement. b. Can only be used in true and false values. c. Can only be used in values -1, 0 or 1. d. Can only be used to take on any expression as a value. How many times will the following loop print hello? i = 1: while (i

Explanation / Answer

1.

ans) b. do..while

why because remaining three(if,switch,if..else) statements are conditional statements. do..while is looping statement.

2.

ans) b. x=+4

it means that x=x+4. and remaining are invalid statements.

3.

ans) c. both a and b are true

unsigned int counter=10;

unsigned int counter={10};

both these statements are acceptable in c++.

4.

ans) d. change total=total-20 to total=total+20.

why because, generally syntactically the code was correct. but if the total was initialized with less number than 1000 .it will execute infinite times. else if the total is assigned with more than 1000 then while loop will not be executed.

so if we change the total=total-20 to total=total+20. it will be executed in the number of times then exited the loop.

and option a and b are totally wrong.

5.

ans) b. can only be used in true and false values.

why because based on the definition of bool type.

6.

ans) b. infinte number of times

why because there is no increment(i++ or i=i+x) statement inside loop.