CS1143- Unit 1

Ace your homework & exams now with Quizwiz!

If you do not follow a consistent programming style, your programs will generate compiler errors.

False

If you want to know the length of the string that is stored in a string object, you can call the objects size member function.

False

The C++ language requires that you give variables names that indicate what the variables are used for.

False

The fixed manipulator causes a number to be displayed in scientific notation.

False

The sequence of statements double dollars = 5; cout << setprecision (5) << dollars << endl; Will output $5.00 to the screen

False

When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive,

False

This stream manipulator forces cout to print floating-point values in decimal notation.

Fixed

cout << "Four\n" << "score\n"; cout << "and" << "\nseven"; cout << "\nyears" << " ago" << endl;

Four Score and Seven Years ago

Names that are defined by the programmer are

Identifiers

Words or names created by the programmer are called

Identifiers

The cin >> statement will stop reading input when it encounters a newline character.

True

When typing in your source code into the computer, you must be very careful since most of your C++ instructions, header files, and variable names are case sensitive.

True

Which of these technologies are non-volatile?

USB flash drive DVD Disc Main memory in a tablet

When computer memory loses its contents when power is removed, we say that the memory is

Volatile

A(n) _______________ is a set of instructions that a computer follows to solve a problem

program

What will the value of x be after the following statements execute? int x = 0; int y = 5; int z = 4; x = y + z * 2;

13

What is the value of the average after the following code executes? double average; average = 1.0 + 2.0 + 3.0 / 3.0;

4

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

4

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

4

What is the value of the number after the following statements execute? int number = 10; number += 5; number -= 1; number *= 3;

42

A variable called "average" should be declared as an integer data type because it will probably hold data that contains decimal places

False

Arithmetic operators that share the same precedence have right to left associativity?

False

The set of rules that must be followed when constructing a program is called

Syntax

When the final value of an expression is assigned to a variable, it will be converted to:

The data type of the destination variable

Which of these storage technologies are RAM

The main memory in a desktop computer The memory in your cell phone

int number = 42; cout << "The number is" << "number" << endl;

The number is number

Write a single line of c++ code that will display your full name on the console. The cursor should be at the beginning of the next line when this output is complete

cout << "Your name here" << endl;

Which of the following statements correctly assigns the character Z to the variable?

letter = 'Z';

Mistakes that cause a running program to produce incorrect results are called:

logic errors

Which of the following statements correctly assigns a string literal to the string object?

name = "Jane";

Which statement is equivalent to the following? number += 1;

number = number + 1;

You can use these to override the rules of operator precedence in a mathematical expression.

parentheses

Division by zero when the program is executing is an example of a ____ error.

run time

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

secondary storage

This stream manipulator forces cout to show the decimal point even for integer values.

showpoint

The rules that govern the correct order and usage of the elements of a language are called the

syntax

A compiler

translates source code into executable code

A location in memory used for storing data and given a name in a computer program is called a _________ because the data in the location can be changed.

variable

________ represent storage locations in the computer's memory.

variables

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

x *= 2;

Write the C++ expression for the following algebraic formula: y = x^4

y = zzzz

Write the C++ expression for the following algebraic formula: z = 5x + -14y - k

z = 5x + 14y - k;

What are the two rules that govern the construction of identifiers?

-The identifiers must not begin with a digit. -After the first character, the identifier May only use letter (either case), digits, and underscore character

In a C++ program, comments are indicated by:

// double slash, like this

Int x = 0, y = 1, z = 2; cout << x << y << z << endl;

012

A unary operator has

1 operand

What is the outcome of the following expression? -6 + 12 * 2 - 8

10

Convert hexadecimal value A3 to decimal

163

What is the outcome of the following expression? (19-3) + (2+2) / 4

17

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

2

What will the value of result be after the following statement executes? result = 6 - 3 * 2 + 7 - 10 / 2 ;

2

A binary operator has

2 operands

Convert the binary value 11110000 to decimal

240

What is the outcome of the following expression? 12 / (10 - 6)

3

A ternary operator has

3 operands

What is the outcome of the following expression? (8 + 7) * 2

30

What is the value of number after the following statements execute?

39

Which of the following would be an illegal identifier?

3dGraph

Convert the decimal value 76 to hexadecimal

4C

(( 19-3) + (2 + 2)) / 4

5

Convert hexadecimal value 3A to decimal

58

Convert the hexadecimal value 3A to decimal

58

Which line in the following program will cause a compiler error? 6 const int MY_VAL; 7 MY_VAL = 77; 8 cout << MY_VAL << endl; 9 return 0;

6

Convert the decimal value 121 to hexadecimal

79

Convert value 01111100 to hexadecimal

7C

Assume that a program has the following variable definition: int a, b = 2; double c = 4.2; and the following statement: a = b * c; What value is stored in a?

8

How many bits are in one byte?

8

The ________ operator always follows the cin object, and the ________ operator follows the cout object.

>>,<<

A bit is

A binary digit, a 0 or a 1.

An example of a secondary storage device is

A hard disk

Which statement best describes a variable and it's primary purpose?

A variable is a named storage location in the computers memory used for holding a piece of information

Internally, the CPU consists of two parts:

ALU and Control Unit

Convert the binary value of 1011 0100 to hexadecimal

B4

In programming, two number bases that are frequently encountered (other than decimal) are

Binary and hexadecimal

A string literal is indicated by

Double quotes, like this: "a"

This stream manipulator forces cout to print floating-point values in exponential notation.

Exp

A character literal is indicated by

Single quotes, like this 'a'

An error created because the programmer violated the rules of grammar or syntax in the language is a

Syntax error

Write a statement that declares the variable finalGrade as a char and initializes it to the letter F.

Char finalGrade = 'F';

An error in a program that involves a violation of language rules will be detected at ____ time.

Compile

A string literal is indicated by

Double quotes

Application software

Is any software that runs with the support of the operating system

What best defines a "programming language"?

It allows us to express an algorithm.

Words in a programming language that have a special meaning and may be used only for their intended purpose are known as

Keywords

Words that have special meaning in a programming language are called

Keywords

This stream manipulator forces cout to left-justify the next item of output in the current field.

Left

An error that causes a program to produce incorrect or unexpected results is a

Logical error

Microsoft Windows, UNIX, and MacOS are examples of

Operating system

A variable declaration announces the name of a variable that will be used in a program, as well as:

The type of data it will be used to hold

Which of the following is true?

There are no language rules regarding statements and line in general

A CPU only understands instructions that are written in machine language

True

A variable must be declared before it can be used in the program.

True

C++ does not have a built in data type for storing strings of characters.

True

Escape sequences are always stored internally as a single character.

True

Write the C++ expression for the following algebraic formula: a = 12x

a = 12 x;

A set of well-defined steps for performing a task or solving a problem is known as a(n):

algorithm

An operating system

allocates resources like memory to programs that are running

At each step of its operation, the input to a Central Processing Unit is

an instruction

Write an assignment statement that adds 2 to the variable a and stored the result in variable b

b = a + 2;

Write an assignment statement that adds 2 to the variable a and stores the result in variable b

b = a + 2;

Write an assignment statement that divides the variable a by 3.14 and stores the result in variable b.

b = a/3.14;

Write an assignment statement that stores the character 'X' in variable ch

ch = 'X';

You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?

cin >> length >> width >> height;

This function tells the cin object to skip one or more characters in the keyboard buffer.

cin.ignore

To have access to mathematical functions such as pow(), sqrt (), and tan () you must include this C++ header file.

cmath

You must have a ___________ for every variable you intend to use in a program.

declaration

Before a variable is used it must be

declared

When a program is not running, it is stored

disk

Which of the following defines a double-precision floating point variable named payCheck?

double payCheck;

Write a single line of code that declares the double variables temp, weight, and age

double temp, weight, age;

When using the stream manipulators from the iostream library, there are three that always go together. If you need any one of them, you need all three. Which three are they? Choose three

fixed showpoint setprecision()

Write the C++ expression for the following algebraic formula: h + 12 g = ————- 4k

g = ( h + 12 ) / ( 4K );

________ reads a line of input, including leading and embedded spaces, and stores it in a string object.

getline

Which statement will read an entire line of input from the keyboard into the following string object? string address;

getline (cin, Address) ;

Three primary activities of a program are:

input, processing, output

Write a statement that declares int variable theAnswer as an int and initialized it to the value 42.

int theAnswer = 42

The numeric data types in C++ are broken into two categories:

integer and floating point

A binary digit

is zero or one

Words that have a special meaning in a programming language are called

key words

What is the outcome of the following expression? 28 / 4 + 3

10

What is the outcome of the following expression? 30 / 4 + 3

10

What is the output of the following statement? cout << 4 * (15/ (1+3)) << endl;

12

Characters and symbols that perform operations on one or more operands are:

Operators

Characters or symbols that perform operations on one or more arguments are

Operators

___ perform operations on one or more operands

Operators

This stream manipulator forces cout to right-justify the next item of output in the current field.

Right

RAM, random-access memory, is called that because

you can pick any two random locations and it will take the same time to access the data


Related study sets

Ch.22- Lymphatic System and Immunity

View Set

Chapter 3 Prenatal development and birth

View Set

Meaning of Extension in other Countries

View Set

Psychology Brain States & Consciousness

View Set

All season driving school final test 2

View Set

PSY 200 Study Guide- Mr Nichols, NWSCC

View Set

Chapter 8 History Layup Questions

View Set

Seeley's Anatomy & Physiology 11th ed Chapter 15

View Set

McFarland USA Important Vocab Words

View Set