CS 1143 Unit 1

Ace your homework & exams now with Quizwiz!

When a program runs on a computer, the part of the computer that carries out the instructions is called the

Central processing unit

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

Compile time

Decision symbol

Diamond

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

Double payCheck;

An algorithm allows ambiguity

False

Arithmetic operators that share the same precedence are processed from right to left

False

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

Machine languages can be used to write programs that can run on any machine.

False

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

False

The fixed manipulator causes subsequent numbers to be displayed in scientific notation

False

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

False

The purpose of testing with different combinations of data is to expose runtime and ________ errors

Logical

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

Logical error

int number = 10; Number += 5; Number -= 1; Number *= 3;

42

Convert the decimal value 76 to hexadecimal

4C

6 + 16 % 3 - 2

5

Convert hexadecimal value 3A to decimal

58

The variable x starts with the value 0 The variable y starts with the value 5 Add 1 to x Add 1 to y Add x and y, and store the result in y Display the value of y on the screen What is displayed on the screen?

7

Convert the decimal value 121 to hexadecimal

79

Convert the binary value 0111 1100 to hexadecimal

7C

Given the following code: int w= 5; int x=4; int y=8; int z=3; X=x*2; What value is stored in the variable x?

8

How many bits are in one byte?

8

In modern computer systems, a byte consists of

8 bits

The _____ operator always follows the cin object, and the _______ operator follows the cout object

>>, <<

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

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

Volatile

contents are lost when power is off

Volatile

_______ 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);

A c/C++ preprocesser directive is indicated by _______

#abc

In a C++ program, comments are indicated by (choose two)

// double slash, /* slash star and star slash

(19-3) % (2+3)

1

A unary operator has ___ operands

1

28/ 4 + 3

10

6 + 17 % 3 + 2

10

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

10

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

10

Convert the hexadecimal value A3 to binary

10100011

Convert the hexadecimal value 3A to binary

111010

cout<< 4 * (15/ (1+3)) << endl;

12

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

13

Convert hexadecimal value A3 to decimal

163

Result = 6 -3 x 2 + 7 -10 / 2;

2

What is the value of average after the following code executes? Double average; Average = (1.0 + 2.0 + 3.0) / 3.0;

2

int w= 5; int x= 4; int y= 8; int z= 3; X= y/x;

2

int x; x = 18%4;

2

4 + 8 * 2

20

6 + 12 * 2 - 8

22

Convert the binary value 1111 0000 to decimal

240

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

3

(8+7) * 2

30

The variable j starts with the value 10 The variable k starts with the value 2 The variable l starts with the value 4 Store the value of j times k in j Store the value of k time l in l Add j, k, and l, and store the result in k Display the value of k on the screen

30

The variable a starts with the value 1 The variable b starts with the value 10 The variable c starts with the value 100 The variable x starts with the value 0 Store the value of c times 3 in x Add the value of b times 6 to x Add the value of a times 5 to x Display the value of x on the screen

365

Which of the following would be an invalid identifier?

3dGraph

double average; average = 1.0 + 2.0 + 3.0 / 3.0;

4

int x; x = 18.0/4;

4

A bit is

A binary digit, like 0 or 1

What statement best describes a variable and its 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

Which of the following are binary operators?

Addition, subtraction, multiplication, fictions, modulus

A byte in memory is identified by a unique number called its

Address

A set of well-defined sets for performing a task or solving a problem is known as a

Algorithm

an operating system

Allocated resources like memory to programs that are running

At each steps of its operation, the input to a central processing unit is

An instruction

What does "random access" mean?

Any location in memory can be accessed in one "addressing cycle" regardless of location.

Flow of control symbol

Arrow

The job of the _____ is to fetch instructions and operands, execute the instructions, and store the result

CPU

Convert the binary value 1011 0100 to hexadecimal

B4

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

Binary (base 2) and hexadecimal (base 16)

Convert the decimal value 211 to hexadecimal

D3

Before a variable can be used it must be

Declared

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

Fixed

When using the stream manipulators from the iostream library to control the appearance of floating-point numbers, there are 3 that always go together. If you need any one of them, you need all 3. Which are they?

Fixed, showpoint, setprecision ()

Which of these is not a programming language? C C++ HTML Java

HTML

Which of these is secondary storage device?

Hard drive disk

Names that are defined by the programmer are

Identifiers

These are named storage locations in the computer memory that contain data:

Identifiers

Words or names defined by the programmer are called

Identifiers

Application software

Is any software that is 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 meanings in a programming language are

Keywords

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

Left

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

Logic errors

Every C++ program must include a

Main function

An example of primary storage device is

Main memory

1 area = width x length 2 display "Please enter the room's width:"; 3 accept width 4 display "Please enter the room's length:"; 5 accept length 6 display area How would you move one line of code to correct this algorithm?

Move line 1 to just below line 5

Contents can be changed

Mutable

Microsoft Windows, UNIX, and MacOS are examples of

Operating systems

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

Operators

______ perform operations on one or more operators

Operators

Start/stop symbol

Oval

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

Parentheses

The ability of a language to let a programmer develop a program on computer system that can be run on other systems is called

Portability

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

Program

Computers can perform many different tasks because they can be

Programmed

C++, Java, and Visual Basic are examples of

Programming languages

Computation symbol

Rectangle

Very high performance and expensive memory tied closely to the processor

Register and cache

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

Right

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

Secondary storage

Flash drives, CD's, and external disks are all examples of

Secondary storage memory devices

This stream manipulator forces cout to show the decimal point in floating-point numbers, even if they are really integer values

Showpoint

A character literal is indicated by

Single quotes , like this: 'a'

The code that a programmer writes is called

Source code

A computer program is a set of

Statements

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

Syntax

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

Syntax error

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

Syntax of the language

The two categories of computer software are (select two)

System software Application software

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

The data type of the destination variable

an example of a secondary storage device is

The hard drive

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

The identifier must not begin with a digit. The identifier May only use letters (upper and lower) digits, and the underscore character

Which of these storage technologies are RAM?

The main memory in a desktop computer

What will the following code display? int number = 42; Cout<< "the number is" << "number" << endl;

The number is the number

Which of these storage technologies are non volatile?

USB flash drive, dvd disks, main memory in a tablet

The negation operator (such as the -in-42) is a ______ operator

Unary

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

Input/output symbol

Trapezoid

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

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

True

There are no language rules regarding statements and lines in general

True

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

True

This function tells the cin object to skip over the next character in the keyboard buffer

cin.ignore()

You want to enter the length, width, and height from the keyboard. Which cin statement accomplishes this?

cin>> length >> width >> height;

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

cmath

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

exp

number += 1;

number= number + 1;

Compilers translate the instructions written by the programmer into

object code

When a program is not running, it is stored

on a disk

Monitors, printers, status lights are all examples of

output devices

When a program runs on a computer, it is stored in

random access memory (RAM)

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

runtime error

A compiler

translates source code into executable code

x = x * 2

x *= 2

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

GACS lclab - English 7 - Wordly Wise 3000 - Book 7, Lesson 7

View Set

Substance Abuse, Eating Disorders, Impulse Control Disorders

View Set

ACCT 302 Test 2 Additional Points

View Set

(PrepU) Psychosocial Well-Being: Nursing Concepts

View Set

Multiple-subject Practice test 2

View Set

Ap government civil liberties and civil rights frqs

View Set

Cardiac NCLEX questions PEDIATRIC

View Set