Exam 2: Flow of Control

arrow
  • Select Tags
search iconSearch Question
  • Select Tags

Write a program that reads in and sums the squares of positive integers until a value that 0 or less is read in.

(Essay)
4.8/5
(38)

Which of the following control structures requires curly braces?

(Multiple Choice)
4.9/5
(31)

For each of the following situations,tell which type loop (while,do-while,or for)would be best in that situation: a)Reading a list of an unknown number of homework grades for a single student. b)Summing a series such as 1 +1/2 +1/(22)+ 1/(23)+ … + 1/(28) c)Testing a newly coded library function to see how it performs for different values of its arguments. d)Reading in the number of days of vacation taken by an employee.

(Essay)
4.8/5
(41)

In a while loop,the Boolean_Expression is executed before each execution of the loop body.

(True/False)
4.7/5
(35)

Write Boolean expressions that represent the given English expressions.Assume any variables used have been declared and initialized. a)alpha is greater than 1 b)x is odd c)x and y are odd d)ch is an upper case alphabetic character (between 'A' and 'Z'). e)digit,which is f type char,has value that is indeed a digit.

(Essay)
4.9/5
(32)

What is the output of the following,if it were embedded in an otherwise correct and complete program and run? int x = 10; While (x > 0) { \quad cout << x << " "; \quad x= x + 3; } cout << endl;

(Multiple Choice)
4.8/5
(40)

Write the following do-while statement with a while construct,and maybe some extra code. x = 10; do { \quad cout << x << endl; \quad x = x - 3; } while ( x > 0 );

(Essay)
4.8/5
(39)

A numeric integer grade is between 50 and 99.Using integer division or otherwise obtain a int value that is 5,6,7,8,or 9 from the numeric grade.Write code using a switch statement using this number in the selector expression that assigns letter grades based on this 10 point scheme: if the numeric_grade is not less than 90,the letter_grade is an A, if the numeric_grade is not less than 80,the letter_grade is a B, if the numeric_grade is not less than 70,the letter_grade is C, if the numeric_grade is not less than 60,the letter_grade is D, otherwise the letter_grade is F.

(Essay)
4.8/5
(29)

When a loop is nested in side another loop,a break or continue statement terminates or restarts the outermost loop of the nested loop structure.

(True/False)
4.9/5
(34)

The value of count is 0;limit is 10.Evaluate: (count != 0)||(limit < 20)

(True/False)
4.8/5
(41)

Which of the following loop statements is guaranteed to iterate the body of the loop at least once?

(Multiple Choice)
4.9/5
(34)

Suppose we have these declarations, int x = -1,y = 0,z = 1; This Boolean expression is correct and it does what the programmer intends. x < y < z

(True/False)
4.9/5
(39)

A switch statement must have

(Multiple Choice)
4.9/5
(32)
Showing 21 - 33 of 33
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)