COP3014 Milestone 1 All TopHat Questions (Chapters 1-5)

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

infinite (endless)

A loop with an incorrect condition or increment will allow program control to get stuck in the loop forever. Such a loop is called an _____________ loop.

3, 2, 1, 4

Arrange the following lines in order to solve the following problem: Write a C++ code snippet to create a char variable. Print it without initializing the variable. Then, initialize the variable with the value 'c' and print it again. 1. variable = 'c' 2. cout << "Before initialization: " << variable << endl; 3. char variable; 4. cout << "After initialization: " << variable << endl;

2, 4, 1, 5, 3

Arrange the following lines to form a C++ code snippet to declare an integer constant with the value 12. Then declare another integer variable. Prompt the user to enter a value and read in the value from the user. The print the sum of the 2 values 1. int value; 2. const int TWELVE = 12; 3. cout << "The sum is: " << TWELVE < + value << endl; 4. cout << "Enter a value: "; 5. cin >> value;

2, 4, 1, 3

Assignment is a process with multiple steps. The following lines are the individual parts of the C++ line answer = total - deductions. Arrange them in the order of processing. 1. the result of the subtraction is carried back to the program from the processor. 2. the values of "total" and "deductions" are taken to the processor from memory 3. The result of the subtraction is assigned as the value to the variable "answer" 4. the subtraction is done in the processor

main

Each c++ executable that is run should have exactly one ________ function, where execution begins

10

How many times does this loop run? int i = 20; while (i < 60) {cout<<i<<endl;i+=4;}

10 15 19

Let us assumer we have a global variable called 'x' with the value 19. What is the output of this code snippets?

identifier, literal, comment, directive, keyword, operator

Match the items to the C++ lexical element: value 5.769 // something here #include <iomanip> return <<

3, 1, 4, 2

Order the following categories of operators in decreasing order of precedence (highest to lowest) 1. relational operator 2. assignment operator 3. arithmetic operator 4. logical operator

a (the variable to store the result of the operation)

The conditional operator takes 3 operands. Which of the following is NOT an operand of the conditional operator? aThe variable to store the result of the operation bThe condition cThe if block d The else block

cout<<static_cast<double>(val1)/val2;

The following lines of code will print 3 as the result. int val1 = 30, val2 = 8; cout<< val1/val2; Edit the last line to print the "Correct" answer 3.75 instead. Please type the full line in without spaces.

b (binary)

The insertion operator << is a unary b binary c ternary d depends on the number of items bring printed

c (linking)

The program is translated into an executable and available for running after which of the following phases? a Preprocessing b Compiling c Linking d Execution

Software Development

This requires deeper knowledge of Computer Science including theory and hardware

Application Development

This requires domain knowledge as well as a general understanding of Computer Science

141310

What is printed by this code snippet?

b

What is the arity of the >> (extraction) operator used in a cin statement? a 1 - The variable to be read in b 2 - the incoming stream from the keyboard and the variable to be read in c 3 - cin, the variable, and the value coming in d Indeterminate - a cin statement can read in multiple values

c (char)

What is the best data type for the value '3'? a int b bool c char d double

1.56

What is the output of the following code snippet?

12

What is the output of the following code snippet?

19115

What is the output of the following code snippet?

32

What is the output of the following code snippet?

631.85

What is the output of the following code snippet?

Negative35

What is the output of the following code snippet?

0 26 5

What is the output of the following code snippet? Please be exact.

35.0

What is the output of the following code snippet? ​

-9

What is the output of the following line? cout << 12 / 6 - 19 + 8 ;

6912

What is the output of this code snippet?

bool

What is the type of the value calculated/evaluated by the relational and logical operators?

23

What is the value in 'ans' after the following lines run? All variables are integers. a = 15, x = 18, z = 44; ans = 25 - z / x % 15;

false

What is the value of "ans" after the following code snippet (true or false)? bool ans;int x = 10, y = 20, z = 30; ans =( z >= y > = x);

software design

When software maintenance is disregarded, what is the longest phase of software engineering?

b

Which if the following is NOT a C++ comment? a // This is a comment b \\ This is a comment c /* this is a comment */ d /* We have */ // 2 comments

b (increment)

Which of the following is NOT a C++ reserved word / keyword? a unsigned b increment c const d static_cast

c (val an integer variable)

Which of the following is NOT a valid case label for a switch statement? a 28 b NUMROWS (an integer constant) c val (an integer variable) d LETTER (a character constant)

d

Which of the following is NOT one of the ways to validate user input? a Check the range and display an error message if the value is outside the range b Use a default value as placeholder if the value is outside the range c Keep asking for a value in the range before proceeding d Use whatever value the user entered - they know what they're doing

d (while)

Which of the following is a C++ keyword? a loop b selection c repeat d while

a

Which of the following is a syntactically correct for loop? a for(int i=0; i<10; i++) b for( i< 20; i++) c for( i<15) d for(int i=0; i<10; cout<<"i"; i++)

d

Which of the following is a valid case label for a switch statement? Select an answer and submit. For keyboard navigation, use the up/down arrow keys to select an answer. a 19.5 b "Hello" c endl d '6'

c (Mouse)

Which of the following is an example of an Input device? a Windows 10 b Printer c Mouse d Network Card

b

Which of the following is equivalent condition to the next line? ! (x >= y && ! (y<z)) a (x <= y && y>=z) b (x <y || y>=z) c (x <y || y < z) d (x <=y && y<z)

d (- negation)

Which of the following operators has the highest precedence (evaluated first)? a % (modulus) b + (addition) c = (assignment) d - (negation)

d

Which of the following operators if the "opposite" or "reverse" of the > operator? a < b != c >= d <=

d (loop initialization)

Which of the following parts of a loop is always executed exactly once? a loop condition b loop increment c loop body d loop initialization

d

Which of the following should not/need not require using a loop? a accumulation b Counting particular occurrences c Recovering from invalid input d Defining Constants

a (iostream)

Which of these is NOT a C++ keyword? a iostream b using c int d return

d (many_numbers)

Which of these is a valid C++ identifier? a 99problems b c@sh$$ c float d many_numbers

c (answer)

Which of these is an L-value? Select an answer and submit. a 25 b "Hello" c answer d 4.6

b (% modulus)

Which of these operators has the highest precedence (evaluated first)? a + (addition) b % (modulus) c = (assignment) d , (comma)

(on paper practice)

Write a C++ code snippet that reads a hexadecimal integer from the user and prints its octal value.Please ue spaces only for literal text and to separate individual C++ statements. Please only write the relevant lines of code. You may assume the variable is an existing integer called "val".

byte

a ________ is the smallest addressable unit of memory in a computer

object oriented

in ______________ languages, objects model real-world objects, not only storing data, but having inherent behaviors

compiled

is c++ compiled or interpreted?

int, char, double, bool

match the data with its data type 35 'a' 3.14 true

syntax

match the premise with the error "I is a programmer"

semantics

match the premise with the error "The headphones ate the tree"

precedence

operator _________ determines which operation is performed first when we have operators of different types on the same line

c b d a e

order the phases of software engineering a testing b design and analysis c requirement gathering d implementation e maintenance

t

t or f We might get unexpected results if we do not initialize variables

memory

the RAM, also referred to as the main __________ is where the program must be placed before it is run

cout

the ______ statement is used to print text to the screen

true

true or false The pre and post increment operators have the same precedence despite having different effects.

true

true or false, Every piece of data in C++ may be evaluated to a truth value of True or False.

false

true or false, Many if statements and a multiple if statement may be used interchangeably without any other changes.

false

true or false, The == operator and the = operator have the same function

true

true or false, The same program could produce different execution paths depending on the values in the variables.

(f) ++ / - <= != && =

true or false, the following operators are arranged from highest to lowest precedence. If false, put the operators in order. ++ / - <= != = &&

std, main, cout, endl

what are the identifiers in this snippet?

3

what is 45 % 7?

9

what is the value of 31 % 11?

b (object oriented language)

which of the following best describes c++? a Procedural Language b Object Oriented Language c Scripting Language d Assembly Language


Ensembles d'études connexes

Chapter 8 - Financing Real Estate Key terms

View Set

Straighterline Chemistry Final- deck 4

View Set

Chapter 8: Earthquakes and Earthquake Hazards

View Set

Human Biology Chapter 12 (Skeletal)

View Set

Marketing Ch. 11 Assigned Reading (SmartBook)

View Set

ATI - DCSMA: Powdered Medications lesson

View Set

Anatomy and Physiology Directional Terms Unit 1

View Set