CMPSCI 101 Exam 1

Ace your homework & exams now with Quizwiz!

The programmer has made an error. What will the following code actually display? int number = 7; cout << "The number is " << "number" << end;

The number is number

There are two items that you must specify with a variable declaration: the variable's name and its ________ .

Type

You can use a ______ to explicitly convert a value from one numeric data type to another, even if the conversion might result in a loss of data.

Type cast expression

You can use a ________ to temporarily convert a value from one numeric data type to another.

Type cast expression

Which of the following is a pre-processor directive, and therefore is not a c++ statement?

#include <iostream>

What is the output of the following statement? cout << 4 + 5 * 10 / 2 << endl;

29

In the following C++ statement, what will be executed first according to the order of precedence (aka the order of operations)? result = 6 - 3 * 2 + 7 - 10 / 2;

3 * 2

What will the value of x be after the following statements execute? int x; x = 18 / 4;

4

In programming terms, a group of characters inside a set of quotation marks is called a:

String Literal

What does the term hardware refer to?

The physical components that a computer is made of

Programmer-defined names of memory locations that may hold data are:

Variables

Which statement is equivalent to the following? x = x * 2;

x *= 2;

Consider the following statements x = 5; y = 10; y = x; After these statements are executed, what is the value of x?

5

Consider the following statements x = 5; y = 10; y = x; After these statements are executed, what is the value of y?

5

Look at the following program and answer the question that follows it. 1 // This program displays my gross wages. 2 // I worked 40 hours and I make $20.00 per hour. 3 #include <iostream> 4 using namespace std; 5 6 int main() 7 { 8 int hours; 9 double payRate, grossPay; 10 11 hours = 40; 12 payRate = 20.0; 13 grossPay = hours * payRate; 14 cout << "My gross pay is $" << grossPay << endl; 15 return 0; 16 } Which line(s) in this program cause output to be displayed on the screen?

14

Consider the following statements x = 5; y = 10; y = x + y; After these statements are executed, what is the value of y?

15

What will the value of x be after the following statements execute? int x; x = 18 % 4;

2

The programmer wants to print a random number. What are the possible values that will be printed by the following statement? cout << rand() % 10 + 100;

A random number between 100 and 109

In a C++ program, two slash marks (//) indicate:

A single-line comment

If we are told that a number is decimal, what base is it in?

Base 10

If we are told that a number is binary, what base is it in?

Base 2

In a(n) ________ numbering system, all numeric values are written as sequences of 0s and 1s.

Binary

A byte is made up of eight ________.

Bits

When creating a variable name, which "case" do we use?

Camel Case

A(n) __________ program translates a high-level language program into a separate machine language program.

Compiler

A ________ is a name that represents a literal value and cannot be changed during the program's execution.

Constant

In C++, you must _______ a variable before you can use it to store data.

Declare

A mouse is an example of:

Input Device

The numeric data types in C++ can be broken into two general categories:

Integer and floating point

If you do not seed the random number generator with srand(), or if you use the same seed value every time you run your program, (for example srand(4)) then you will get the same "random" numbers every time. (T/F)

True

Machine language is the only language that a CPU understands (T/F)

True

The newline escape character \n is functionally equivalent to endl. (T/F)

True

If you want to use the time(0) function to seed the random number generator, which library must you #include?

ctime

The computers's main memory is commonly known as:

RAM

Even when there is no power to the computer, data can be held in:

Secondary Storage

The statements written by the programmer are called:

Source Code

A variable called average should be declared as an integer data type because it will probably hold data that contains decimal places. (T/F)

False

Assembly language is considered a high-level language. (T/F)

False

In C++, uppercase and lowercase letters are considered the same (case-insensitive.) (T/F)

False

Programming in C++ can only be done from a computer that runs Windows, since Microsoft Visual Studio only runs on Windows and there are no other C++ compilers for computers that run Mac or Linux. (T/F)

False

Today, CPUs are huge devices made of electrical and mechanical components such as vacuum tubes and switches. (T/F)

False

Variable names can have spaces in them. (T/F)

False

char literals are enclosed in double quotation marks. (T/F)

False

Every C++ program must have a:

Function main

A ________ performs a calculation and gives a value.

Mathematical Expression

Today's CPUs are small chips known as:

Microprocessors

A(n) _________ is a set of instructions that the computer follows to perform a task.

Program


Related study sets

Political/religious structure of jesus's time

View Set

Chapter 10 Nutrition Strategies for Maximizing Performance

View Set

Ch 7: Characters, Strings, and the StringBuilder

View Set

Fin 7, FIN C5, C1 - Nature of Law, C1 - Nature of Law

View Set

World Geography Semester 1 Final 9th Grade

View Set

Chapter 42- Sonographic and Doppler Evaluation of the Female Pelvis

View Set

Chapter 33 Assessment and Management of Patients with Allergic Disorders

View Set

Physics final practice quizes 29,30,32

View Set