C++

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

The __________ is the Not logical operator, which is used to reverse the truth value of a Boolean expression

!

String literal constants consist of one or more characters enclosed in __________.

" " (double quote)

Which arithmetic operator has the highest precedence?

(

Chose the correct C++ arithmetic operator precedence order from the following.

(, -, *, /

Which of the following C++ code fragments represent the flow chart shown on the attachment? (Click on the attachment to view the flow chart).

// begin int A = 0; int B = 0; cout << "Enter the value of A: "; cin >> A; if (A >= 0) { B = A; } else { B = abs(A); B = sqrt(B); } // end

In the following C++ code fragment, what is the value of variable a after the the statements run? //Begin code fragment int a = 0; int b = 10; if (a == 75 || b != 100) b = a; else a = b; //What is the value of a?

0

What is the value of the variable a after at the end of the following code fragments? int a = 1; if (a = 0) { a = 1; } else { a = 0; }

1

What is the value of variable a when the statements are run? //Begin int a = 1; int b = 2; int c = 3; if (a == b && b == c) { for (a = b = c = 0; a <= 10; a++) { b = a++; c = a++; } a++; } // end if

1

In the following C++ code fragment, what is the value of variable a after the the statements run? //Begin code fragment int a = 0; int b = 10; if (a == 75 && b == 100) b = a; else a = b; //What is the value of a?

10

In the following C++ expressions, the correct display of the output format is.... double sales_figure = 123456.789; cout << fixed; cout << sales_figure << endl;

123456.789000

In the following C++ statements, what is the value of variable a when the statements are run? //Begin int a = 1; int b = 2; int c = 3; if (a != b || b != c) { for (a = b = c = 0; a <= 10; a++) { b = a++; c = a++; } a++; } // end if

13

Choose one C++ variable name that is NOT allowed.

1ConstVariable

What is the value of variable a when the statements are run? //Begin int a = 1; int b = 2; int c = 3; if (a == b && b == c) { for (a = b = c = 0; a == 10; a++) { b = a++; c = a++; } } else { a++; } // end if // end of code fragments

2

What is the value is displayed after executing C++ code fragments? int a = 0; int b = 1; int c = 2; int d = 3; if ((a != b || a == b) && (c != d || c == d)) { a = b = c; } else { c = b = a; } cout << "The value of a is " << a << end;

3

In C++, the double data type takes _________ bytes of memory space.

8

In C++, which of the following is an assignment operator?

=

What is the closest definition of a computer algorithm?

A set of computer instructions

Implicit data type conversion happens in which of the following C++ scenarios?

All of the above

In C++, "Stream" is a...

Arbitrary sequence of characters

This variable type can take value of TRUE or FALSE.

Bool

Inside of a condition evaluation expression, such as if ( A != B ) is called ___________.

Boolean

What is the value of variable c when the statements are run? // begin char a = 'a'; char b = 'b'; char c = 'c'; a = b = c; if (a == b || b == c) a = toupper(tolower(a)); else a = tolower(toupper(a)); // end

C

In programming design, we use flow chart to visualize the flow of the program. The diamond shape block is called...

Decision

A string literal must be enclosed in a pair of...

Double quotes - " "

The static_cast operator does...

Explicitly converts one data type to another type

In C++, the following statement is allowed without causing an error:

False

In C++, you must use ALL UPPER CASE for symbolic constants's variable name.

False

What is the role of the index or counter in a loop control structure.

Limits the number of iterations

There is a logic error in the below C++ code. The below code always produces the insurance premium of $50. You want to be able to set the premium based on the age. Which explanation is the correct explanation why this code fragment does not work? 1 // begin 2 int age = 0; 3 int premium = 0; 4 age = 10; 5 6 switch (age >= 0) { 7 case (0): 8 premium = 0; 9 break; 10 case (10): 11 premium = 25; 12 break; 13 case (25): 14 premium = 100; 15 break; 16 default:17 17 premium = 50; 18 } // end of switch 19

Logic error in the switch statement on line 6

What is the purpose of performing desk check of your algorithm? (Choose the most correct answer)

Make sure that the algorithm is correct and input and output are correct

All statements in C++ must end with a(n) ____

Semicolon

An algorithm is a... (choose the most correct answer)

Step-by-step description of how a problem is solved

Aside from the multiple-alternative form of the if/else statement, in C++ the _____ statement can sometimes be used to implement a multiple-alternative selection structure.

Switch

In the following C++ variable declaration examples, what are the main difference? const char aChar = 'A'; and const char aChar = "A";

The variable is initialized on the first example; 2nd example attempts to assign a string to character. This is an error.

Why using a flow chart is a good idea, even if you complete your IPO chart? Choose the most correct answer.

To show the program sequence and the flow visually to aid troubleshooting

In order for a compound condition using the && operator to be true, both sub-conditions must be true

True

Sequencing is a type of control structure.

True

The following two expressions are functionally equivalent and do the same thing: Expression 1: if (foo == 'R' || foo == 'r') Expression 2: if (toupper(foo) == 'R')

True

You can nest a selection structure within either the ___ path or ____ path of another selection structure.

True, False

In C++, when does promotion of data type happen?

Using explicit static_cast() conversion

If I want to assign an single character A to a variable a, which is the correct C++ syntax?

a = 'A';

In the following C++ code fragment, if ('A' >= 'a') { cout << "A is greater than a"; } else { cout << "a is greater than A"; } What output do you get?

a is greater than A

In C++ and other programming languages, __________ is a numeric variable used to add up several values.

accumulator

The numbering system that represents the digits with 1 and 0 is called...

binary

The _____ statement tells the computer to stop processing the switch statement at that point.

break

A switch statement contains multiple _______ clauses, each representing a different alternative.

case

Which of the following stream expression stores a value from the keyboard to a variable foo?

cin >> foo;

In C++, the symbols, // designates a beginning of...

comments

A program that takes high-level programming instructions like C++, and turns it into an executable machine code by checking the syntax and linking with other included modules is called...

compiler

The plus (+) operator is used for _______ strings together.

concatenating

Loops controlled using a counter instead of a sentinel value are called __________ loops.

counter controlled

__________ and __________ are used within a repetition structure to calculate subtotals, totals, and averages.

counter, accumulators

An assignment statement assigns a new value to an existing variable, whereas a(n) __________ statement creates a new variable.

declaration

In C++, a(n) _______ clause can be used to provide instructions that are executed if the selector expression doesn't match the value of any case clause.

default

In C++, which of the following numeric data types have the most number of bytes?

double

The __________ method in iostream determines whether the last character in a file has been read

eof()

To test if iostream object has reached the end of the input, you use ____ method.

eof()

In C++, the = is an assignment operator. What is == operator?

equality comparison

You can use the __________ function or methond of the string class to remove one or more characters located anywhere in a string variable

erase

Multiple-alternative selection structures are also called __________ selection structures.

extended

Which type of C++ iostream operator is used to input characters from the keyboard to a string?

extraction

In C++, you can mix lower case and upper case letter for variable names, as long as the variable name starts with a number.

false

Loop counter initialization can happen before, during, and after the body of a loop is processed.

false

In using the flow chart, if the condition evaluates to false, then the flow is take to...

false path

Similar to the while statement, the ___ statement can be used instead to code a pretest loop in C++.

for

A block of code in C++ that performs a specific task is known as a(n) __________. This term applies to main() also.

function

The return data type of a function is contained in the function __________

header

C++ functions consist of two parts, a(n) __________ and a(n) __________.

header, body

The act of updating, also called __________, means adding a number to the value stored in a counter or accumulator.

incrementing

Usually when you include an unnecessary nested selection structure, the program will produce the correct results but will be __________. While the program performance may be OK for smaller program, on a larger program the negative effect is more pronounced.

inefficient

A(n) __________ loop is a loop that processes its instructions indefinitely due to logic error.

infinite

__________ of loop counter happens once, before the body of a loop is processed.

initialization

In C++, the __________ and __________ arguments of the for clause/loop are optional.

initialization, updating

Typically, when using them, the two tasks associated with counters and accumulators are __________ and __________.

initializing, updating

Another common logic error made when writing selection structures is to reverse the __________ and __________ selection structures.

inner, outer

Which of the following C++ expressions are correct syntax for type casting?

int A = 3; int B = 4; double results; results = static_cast<double>(A / B);

In C++, when does promotion of data type happen?

int to double

To use the fixed, scientific or setprecision() in C++, you must include which module?

iomanip

You use the __________ mode of the open function when you want to add data to the end of an existing file

ios:app

Cin and Cout streams are defined in

iostream module

To test if the file you specified to open in iostream, you use ____ method.

is_open()

When an array is sorted in ascending order, the last element in the array contains the __________ value

largest

A variable's __________ indicates how long the variable remains in the computer's internal memory.

lifetime

Unlike variables and named constants, ______ constants are not memory locations

literal

__________ variables can be used only by the function in which they are declared or in whose parameterList they appear

local

Using a compound condition rather than a nested selection structure can, and is a typical __________ error made when writing selection structures.

logic

The following C++ program results in syntax error, "symbol cout not found." What is the likely cause? using namespace std; int main() { const double PI = 3.1459; double length = 0.0; double height = 0.0; area = length * height; cout << "The total area is : "; cout << area << endln; } //end of main program

must have #include <iostream> in the program

Another typical logic error made when writing selection structures is to use an unnecessary __________ selection structure

nested

In C++ selection structure, there are at times that require multiple selections structures in a cascading fashion. An inner selection structure is also referred to as a(n) __________ selection structure. Choose the official term used in the text and in our course.

nested structure

Base 10 means decimal numbering system. Base 2 means binary numbering system. What is Base 8?

octal numbering

You use input and output file objects, along with the __________ function, to open actual files on your computer's disk.

open

The outer and inner selection structures of a nested selection structure, respectively, make the __________ and __________ decisions needed to solve a problem.

pimary, secondary

In a(n) _____ loop, the evaluation occurs after the instructions within the loop are processed.

post test

A repetition structure can either be a(n) __________ loop or __________ loop.

pre-test, post-test

The __________ of an arithmetic operator determines in what order it is evaluated in a given expression

precedence

In a(n) _____ loop, the loop condition is evaluated before the instructions within the loop are processed.

pretest

The built-in ________ function can be used to generate random integers within a specific.

rand

The float and double data type in C++ stores ______ numbers.

real

The ___________ statement of a function returns a value to the calling function

return

In C++, a ";" character is used to... (check all that are correct)

separate statements, terminate a line

The ______________ stream manipulator allows you to display real numbers in a number of fixed digit precision, as in this example of 10.01 for displaying 2 decimal places.

setprecision

Suppose that you want to round up all the sales figure from a C++ program to the whole dollar amount (not including any cents) which stream manipulator will you use?

setpricision(0)

A tab, a space, and newline are all considered to be while-space in C++.

true

A(n) array is a group of variables that have the same name and data type and are related in some way.

true

In C++ language main() is a function, and can appear anywhere in the program file.

true

In C++, all programming codes are contained in funmctions, including main function. Is this true or false?

true

In C++, the following statement is not allowed, therefore causing an error: a + b = c;

true

In the example below, parenthesis ( or ) has lower precedence than a negation ! (not) operator. True or false?

true

Selection structure is also know as decision structure.

true

The condition argument of a for clause specifies when to process the instructions in the loop body. True or false?

true

The logical operators, == and != have the same evaluation precedence.

true

Void functions are not required to contain a(n) return statement

true

In C++, an act of explicitly converting one data type to another data type is called...

type casting

There are two types of functions. Functions are either void or __________.

value returning function

To declare a function header of a void function, it must begin with the keyword _______.

void


Set pelajaran terkait

1Z0-1047-22: Oracle Absence Management Cloud 2022 Implementation Professional

View Set

Pharmacology Chapter 52: Drugs Affecting Coagulation

View Set

Liver/Hep & DKA/HHS Evolve N3 Practice Questions

View Set

GS ECO 302 CH 9 Estimation and Confidence Intervals

View Set

Macroeconomics chapter 8 macro my lab

View Set