COSC 1436 final

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

True

A return statement returns only one value.

int func(int, double, char, string);

Consider the following function definition: int func(int x, double y, char u, string name) { //function body } Which of the following is a correct function prototype of the function func?

2

Consider the following function prototypes: int func1(int x, double y); double func2(string, int, double); char func3(int, int, double, char); string join(string, string); How many parameters does the function func1 have?

4

How many bytes are needed to store: "\\n\\"

+

addition

=

assignment

/

division

;

end of a complete statement

key word

reserved word in a program

-

subtraction or negation

main memory

when a program is running, it is stored here

bit

0 or 1

False

In an infinite while loop, the while expression is always false.

!

Not

#

beginning of preprocessor

/* */

block comment

True

cout is an output stream which typically sends data to the screen.

' '

used to signify a character

" "

used to signify a string

secondary storage (disk drive)

when a program is not running, the program is stored here

pseudocode

when you use an informal mixture of C++ and ordinary language to "outline" your program

operators

+, -, *, = are all examples of this

True

A function prototype includes (a) the function type, (b) the function name, (c) the number of parameters, and (d) the parameter types.

True

A loop is a control structure that causes certain statements to execute over and over while a condition is met.

True

A programmer writes source code and then the compiler/linker converts the source code into machine instructions or executable code.

False

An input stream is a stream from a computer to a destination (e.g., screen or file)

&&

And

Symbol: 4 num1: 18 num2: 7

Based on the following code and the following input, what will be the value in the following variables after the cin line: int num1, num2; char symbol; cout << "Enter the data: "; cin >> symbol >> num2 >> num1; Input: 47 18 * 28 $

Erroneous value

Based on the following code and the following input, what will be the value in the variable num3 after the cin line: int num1, num2, num3; char symbol; cout << "Enter the data: "; cin >> num1 >> symbol >> num2 >> num3; Input: 48 18 * 28 $

True

C++ provides the user a standard set of predefined functions (that you may or may not use).

True

Each byte in memory is identified by a unique number known as an address.

False

Every if statement must have an else.

False

Executing a break statement in the body of a loop immediately terminates the program.

2

How many bytes are needed to store: "\n"

2

How many bytes are needed to store: "n"

1

How many bytes are needed to store: '\n'

1

How many bytes are needed to store: 'n'

6 times

How many times will the inner loop body iterate? int row = 0; int col = 0; for(row = 0; row < 2; row = row + 1) { for(col = 0; col < 3; col = col + 1) { // Inner loop body } }

False

If a user enters a number at the monitor, and then the program stores that number into a variable called num, your program should include the line: cin << num;

False

In C++, the names of the corresponding formal and actual parameters (the parameter names in the function heading and the function call) must be the same.

False

Machine language code can be moved and run on any machine.

||

Or

True

Programmer-defined Identifiers are names made up by the programmer

outfile.open("travel.txt");

Suppose you have the following code: ofstream outfile; double distance = 375; double speed = 58; double travelTime; What C++ statement would you have to include to open the file travel.txt using the variable outfile.

outfile << distance << speed << endl;

Suppose you have the following code: ofstream outfile; double distance = 375; double speed = 58; double travelTime; What C++ statement would you have to include to write out the values of the variables distance and speed into the output file.

False (only true for passing by value. When you pass by reference you must pass a variable)

The corresponding actual parameter in function call when you pass by reference or value can be an expression, a variable, or a constant value.

break

The execution of a ______ statement in a switch statement immediately exits the switch structure.

True

The function ignore (used as cin.ignore(100,'n') for example) is used to skip certain input in a line.

fstream

To read or write to a file, you must use the following header file:

False

Use the operator >> with cout.

False

Variables declared within a function (or block) are called global variables.

True

Variables defined in the function heading are called formal parameters.

units is promoted to a float, mass remains a float, and he result of mass*units is a double

What automatic data type conversion will take place? int units; float mass; double weight; weight = mass * units;

string

What is the correct data type of this literal: "Hello"

string

What is the correct data type of this literal: "X"

char

What is the correct data type of this literal: 'X'

int

What is the correct data type of this literal: -342

double/float

What is the correct data type of this literal: 9.0

bool

What is the correct data type of this literal: true

4S

What is the output from the following lines: cout << static_cast<int> (4.75); cout << static_cast<char> ('R' + 1);

6 3

What is the output of the following code: #include <iostream> #include <cmath> using namespace std; int mystery(int&, int); int main () { int z=5, a; a=mystery(z,3); cout << z << " " << a << endl; } int mystery(int& x, int y) { x=y*2; return y; }

A

What is the output of the following statements: if ('a' < 'A') cout << 'a'; cout << 'A';

nested

When one decision statement is located within another, it is said to be ___________ if statements

iostream

When using cin and cout, the program must include the header file:

False

When you pass by reference you return the value via the return statement.

iomanip

Which header file must be included when using the following: setprecision

cmath

Which header file must be included when using the following: sqrt

1stNum

Which of the following is NOT a legal identifier? _firstNum num_1 first_num 1stNum firstNum

SynLang

Which of the following is NOT a programming language? C# Ruby BASIC FORTRAN Swift Python SynLang Java

Constant identifier names must be written in all caps

Which of the following is NOT true regarding named constants? Use the following keyword to define a constant: const Constant identifier names must be written in all caps. An initialization value must be given at a declaration/definition time. A compiler error will occur if a statement attempts to change the value of a constant.

if(age>21)

Which of the following would correctly test to see if the person in question is at least 21. The person's age will be restored in the variable: age

True

While and for loops are called pretest loops and a do...while loop is called a posttest loop

b=a+2

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

b=a-8

Write a statement that subtracts 8 from the variable a and stores the result in the variable b.

True

You can use the stream function clear, such as cin.clear(), to restore the input stream to a working state (clearing the input stream)

{ }

enclose a group of statements (such as lines in a function)

\

escape character

fixed

formats the output in the fixed decimal format

setw

formats the output of an expression in a specific number of columns; the default output is right-justified

setprecision

formats the output to a specified number of decimal places

False

int x=5, quotient; quotient = 101/5; The value in quotient after the above lines are executed is 20.2

run-time error

logic errors

%

modulus/remainder

*

multiplication

variable

named storage location in the computer's memory

endl

new line

showpoint

outputs floating-point numbers with a decimal point and trailing zeros

system software (ex. operating system)

programs that manage the computer hardware and the programs that run on them

application software (ex. word processor or game)

programs that provide services to the user

algorithm

set of well-defined steps

//

single line comment

compile-time error (remember syntax mistakes are found by the compiler)

syntax-type errors

portability

the ability of a language to let a programmer develop a program on a computer system that can be run on other systems ( you can run a program on more than one system )

source code (.cpp file for C++)

the actual code that the programmer writes

object code

the code created by the compiler

program

the instructions in a computer memory to make it do something

CPU

the part of the computer that carries out the instructions (retrieves and decodes the instructions)

syntax

the rules of grammar that must be followed when writing a program

setfill

used to fill the unused columns with a character other than a space

byte

8 bits


Ensembles d'études connexes

Ch. 7 Episodic and Semantic Memory

View Set

Paraphrasing, Summarizing, Quoting, and Citing Research

View Set

Patho Chapter 48 neurobiology of psychotic illnesses

View Set

Ch 16: Postoperative Nursing Management

View Set