itcs 1212 final

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

True/False: An expression that has any value other than 0 is considered true by an if statement.

true

This operator is known as the logical OR operator. Select one: a. -- b. // c. # d. ||

d.||

True/False: When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive.

false

The ________ operator always follows the cin object, and the ________ operator follows the cout object. Select one: a. binary, unary b. conditional, binary c. >>, << d. <<, >> e. None of these

c. >>, <<

These are used to declare variables that can hold real numbers. a. Integer data types b. Real data types c. Floating point data types d. Long data types e. None of these

c. Floating point data types

Associativity is either right to left or: Select one: a. Top to bottom b. Front to back c. Left to right d. Undeterminable e. None of these

c. Left to right

Whereas < is called a relational operator, x < y is called a ________. Select one: a. Arithmetic operator b. Relative operator c. Relational expression d. Largeness test e. None of these

c. Relational expression

Which statement will read an entire line of input into the following string object? string address; Select one: a. cin << address; b. cin address; c. getline(cin, address); d. cin.get(address); e. None of these

c. getline(cin, address);

What will the following code display? cout<<"Monday"; cout<<"Tuesday"; cout<<"Wednesday"; Select one: a. Monday Tuesday Wednesday b. Monday Tuesday Wednesday c. "Monday" "Tuesday" "Wednesday" d. MondayTuesdayWednesday

d. MondayTuesdayWednesday

This statement will pause the screen, until the [Enter] key is pressed. Select one: a. cin; b. cin.input(); c. cin.getline(); d. cin.get(); e. cin.ignore();

d. cin.get();

What will the following program display? #include <iostream> using namespace std; int main() { int a = 0, b = 2, x = 4, y = 0; cout << (a == b) << " "; cout << (a != b) << " "; cout << (b <=x) << " "; cout << (y > a) << endl; return 0; } A) 0 1 1 0 B) 0 0 1 0 C) 1 1 0 1 D) 1 0 0 1 E) None of these

A)0110

What is the value of cookies after the execution of the following statements? int number =38, children=4, cookies; cookies=number%children; a. 2 b. 0 c. 9 d. .5 e. None of these

A.2

Which line in the following program will cause a compiler error? 1 #include <iostream> 2 using namespace std; 3 4 int main() 5 { 6 int number = 5; 7 8 if (number >= 0 && <= 100) 9 cout << "passed.\n"; 10 else 11 cout << "failed.\n"; 12 return 0; 13 } A) 6 B) 8 C) 10 D) 9

B) 8

What will the following code display? int number = 7; cout << "The number is " << "number" << endl; A) The number is 7 B) The number is number C) The number is7 D) The number is 0

B) The number is number

This operator is used in C++ to represent equality. Select one: a. = b. >< c. !! d. == e. None of these

d. ==

What is the output of the following code? int w = 98; int x = 99; int y = 0; int z = 1; if (x >= 99) { if (x < 99) cout << y << endl; else cout << z << endl; } else { if (x == 99) cout << x << endl; else cout << w << endl; } A) 98 B) 99 C) 0 D) 1

D) 1

Given that, x = 2, y = 1, and z = 0, what will the following cout statement display? cout<<"answer="<<(x||!y&&z)<<endl; Select one: a. answer = 0 b. answer = 1 c. answer = 2 d. None of these

b. answer = 1

What is the value of the following expression? true||true Select one: a. -1 b. true c. false d. +1

b. true

This operator performs a logical NOT operation. Select one: a. -- b. ! c. <> d. >< e. None of these

b.!

This manipulator causes the field to be left-justified with padding spaces printed to the right. Select one: a. left_justify b. right c. left d. left_pad e. None of these

c. left

What will the following program segment display? int funny = 7, serious = 15; funny = serious % 2; if (funny != 1) { funny = 0; serious = 0; } else if (funny == 2) { funny = 10; serious = 10; } else { funny = 1; serious = 1; } Select one: a. 7 15 b. 0 0 c. 10 10 d. 1 1

d.11

True/False: The default section is required in a switch statement.

false

True/False: If the sub-expression on the left side of the || operator is true, the expression on the right side will not be checked.

true

The float data type is considered ________ precision, and the double data type is considered ________ precision. a. single, double b. float, double c. integer, double d. short, long e. None of these

a. single, double

What will the value of x be after the following statements execute? int x; x = 18 % 4; a. 2 b. 4 c. 0.45 d. unknown

a.2

What is the value of the following expression? true&&false Select one: a. +1 b. true c. false d. -1

c. false

True/False: You should be careful when using the equality operator to compare floating point values because of potential round-off errors.

true

t/f Both of the following if statements perform the same operation. if (sales > 10000) commissionRate = 0.15; if (sales > 10000) commissionRate = 0.15;

true

Which statement allows you to properly check the char variable code to determine whether it is equal to a "C" and then output "This is a check" and then advance to a new line? A) if code is equal to C cout << "This is a check\n"; B) if (code = "C") cout << "This is a check" << endl; C) if (code == 'C') cout << "This is a check\n"; D) if (code == C) cout << "This is a check" << endl;

c. if (code == 'C') cout << "This is a check\n";

The default section of a switch statement performs a similar task as the ________ portion of an if/else if statement. Select one: a. conditional b. break c. trailing else d. All of these e. None of these

c. trailing else

What will be the value of result after the following code has been executed? int a = 60; int b = 15; int result = 10; if (a = b) result *= 2; A) 10 B) 120 C) 20 D) This code will not compile

c.20

The ________ of a variable is limited to the block in which it is declared. Select one: a. precedence b. associativity c. scope d. branching ability

c.scope

Which of the following expressions will determine whether x is less than or equal to y? Select one: a. x > y b. x =< y c. x >= y d. x <= y

d. x <= y

What is the value of donuts after the following code executes? int donuts = 10; if (donuts = 1) donuts = 0; else donuts += 2; a. 2 b. 10 c. 0 d. 12

d.12

Given the following code segment, what is output after "result = "? int x = 1, y = 1, z = 1; y = y + z; x = x + y; cout << "result = " << (x < y ? y : x) << endl; A) 0 B) 1 C) 2 D) 3 E) None of these

d.3

What is the output of the following statement? cout<<4*(15/(1+3))endl; a. 15 b. 12 c. 63 d. 72 e. None of these

12

What will the following code display? cout << "Four " << "score "; cout << "and " << "seven/n"; cout << "years" << "ago" << endl; A) Four score and seven yearsago B) Four score and seven years ago C) Four score and seven/nyearsago D) Four score and seven yearsago

C) Four score and seven/nyearsago

Character constants in C++ are always enclosed in ________. a. 'single quotation marks' b. "double quotation marks" c. {braces} d. (parentheses) e. [brackets]

a. 'single quotation marks'

Which one of the following would be an illegal variable name? Select one: a. 3dGraph b. dayOfWeek c. June1997 d. itemsorderedforthemonth e. _employee_num

a. 3dGraph

Which is true about the following statement? cout<<setw(4)<<num4<<""; Select one: a. It allows four spaces for the value in the variable num4. b. It outputs "setw(4)" before the value in the variable num4. c. It should use setw(10) to output the value in the variable num10. d. It inputs up to four characters stored in the variable num4. e. None of these

a. It allows four spaces for the value in the variable num4.

This statement uses the value of a variable or expression to determine where the program will branch to. Select one: a. switch b. select c. associative d. scope e. None of these

a. switch

What will the value of x be after the following statements execute? int x; x = 18.0 / 4; a. 0 b. 4 c. 4.5 d. unknown

b. 4

These operators connect two or more relational expressions into one, or reverse the logic of an expression. Select one: a. relational b. logical c. irrational d. negation e. None of these

b. logical

If you use a C++ key word as an identifier, your program will: a. Execute with unpredictable results b. not compile c. understand the difference and run without problems d. Compile, link, but not execute e. None of these

b. not compile

What is the value stored at x, given the statements: int x; x=3/ static_cast<int>(4,5+6.4); Select one: a. .3 b. 0 c. .275229 d. 3.3 e. None of these

b.0

What will the value of x be after the following statements execute? int x; x = 18 / 4; a. 0 b. 4 c. 4.5 d. unknown

b.4

What is the modulus operator? a. + b. & c. % d. * e. ||

c. %

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? Select one: a. 8 and 9 b. 13 c. 14 d. 13 and 14 e. 15

c. 14

Which of the following defines a double-precision floating point variable named payCheck? Select one: a. float payCheck; b. Double payCheck; c. double payCheck; d. payCheck double;

c. double payCheck;

This operator represents the logical AND. Select one: a. ++ b. || c. && d. @ e. None of these

c.&&

In C++ 11, if you want an integer literal to be treated as a long long int, you can append ________ at the end of the number. Select one: a. L b. <INT> c. I d. LL e. None of these

d. LL

The total number of digits that appear before and after the decimal point is sometimes referred to as: Select one: a. floating points b. significant digits c. precision d. significant digits and precision e. None of these

d. significant digits and precision

The function, pow(x, 5.0), requires this header file. Select one: a. iomanip b. cstdlib c. iostream d. cstring e. cmath

e. cmath

Every complete C++ program must have a ________. a. cout statement b. preprocessor directive c. comment d. symbolic constant e. function named main

e. function named main

True/False: When the fixed manipulator is used, the value specified by the setprecision manipulator will be the number of digits to appear after the decimal point.

true

This is used to mark the end of a complete C++ programming statement. a. Pound Sign b. Semicolon c. Data type d. Void e. None of these Feedback

B.semicolon

What will the following code display? cout << "Four" << "score" << endl; cout << "and" << "seven" << endl; cout << "years" << "ago" << endl; A) Four score and seven years ago B) Four score and seven years ago C) Fourscoreandsevenyearsago D) Fourscore andseven yearsago

D) Fourscore andseven yearsago

What will the following code display? cout << "Four\n" << "score\n"; cout << "and" << "\nseven"; cout << "\nyears" << " ago" << endl; A) Four score and seven years ago B) Four score and seven years ago C) Four score and seven years ago D) Four score and seven years ago

Four score and seven years ago

When converting some algebraic expressions to C++, you may need to insert ________ that do not appear in the algebraic expression. Select one: a. Parentheses b. Exponents c. Calculations d. Coercions e. None of these

a. Parentheses

In programming terms, a group of characters inside a set of quotation marks is called a: a. String literal b. Variable c. Operation d. Statement e. None of these

a. String literal

In C++ 11, the ________ tells the compiler to determine the variable's data type from the initialization value. Select one: a. auto key word b. #include preprocessor directive c. variable's name d. dynamic_cast key word e. None of these

a. auto key word

Without this statement appearing in a switch construct, the program "falls through" all of the statements below the one with the matching case expression. Select one: a. break b. exit c. switch d. scope e. None of thes

a. break

This function tells the cin object to skip one or more characters in the keyboard buffer. Select one: a. cin.ignore b. cin.jump c. cin.hop d. cin.skip; e. None of these

a. cin.ignore

When a program lets the user know that an invalid choice has been made, this is known as: Select one: a. input validation b. output correction c. compiler criticism d. output validation e. None of these

a. input validation

Which statement is equivalent to the following? number+=1; Select one: a. number = number + 1; b. number + 1; c. number = 1; d. None of these

a. number = number + 1;

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; Select one: a. 13 b. 18 c. unknown d. 0

a.13

After execution of the following code, what will be the value of input_value if the value 0 is entered at the keyboard at run time? cin>>input_value; if(input_value>5) input_value=input_value+5; else if(input_value>2) intput_value=input_value+10; else input_value=input_value+15; Select one: a. 15 b. 10 c. 25 d. 0 e. 5

a.15

What will be the output of the following code segment after the user enters 0 at the keyboard? int x=-1; cout<<"Enter a 0 or a 1 from the keyboard:"; cin>> x; if(x) cout<<"true"<<endl; else cout<<"false"<<endl; Select one: a. false b. x c. true d. Nothing will be displayed.

a.false

The statement: cin>>setw(10)>>str; will read up to this many characters into str. Select one: a. Nine b. Ten c. Eleven d. Eight e. None of these

a.nine

You can use these to override the rules of operator precedence in a mathematical expression. Select one: a. [Brackets] b. (Parentheses) c. {Braces} d. The escape character \ e. None of these

b. (Parentheses)

Assuming you are using a system with 1-byte characters, how many bytes of memory will the following string literal occupy? "William" Select one: a. 1 b. 8 c. 14 d. 7

b. 8

What will the following segment of code output if 11 is entered at the keyboard? int number; cin >> number; if (number > 0) cout << "C++"; else cout << "Soccer"; cout << " is "; cout << "fun"; select one: a. C++fun b. C++ is fun c. C++ d. Soccerfun e. Soccer is fun

b. C++ is fun

If you place a semicolon after the statement: if(x<y) Select one: a. The code will not compile. b. The compiler will interpret the semicolon as a null statement. c. The if statement will always evaluate to false. d. All of these e. None of these

b. The compiler will interpret the semicolon as a null statement.

________ must be included in any program that uses the cout object. a. Opening and closing braces b. The header file iostream c. Comments d. Escape sequences e. None of these

b. The header file iostream

This control sequence is used to skip over to the next horizontal tab stop. Select one: a. \' b. \t c. \a d. \n e. \h

b. \t

In C++ the = operator indicates: Select one: a. equality b. assignment c. subtraction d. negation e. None of these

b. assignment

You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written? Select one: a. cin >> length, width, height; b. cin >> length >> width >> height; c. cin.get(length, width, height); d. cin << length; width; height; e. cin << length, width, height;

b. cin >> length >> width >> height;

The ________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed. Select one: a. Output stream b. cin object c. cout object d. Preprocessor e. None of these

b. cin object

In any program that uses the cin object, you must include the ________. Select one: a. compiler b. iostream header file c. linker d. >> and << operators e. None of these

b. iostream header file

ssume that a program has the following variable definition: char letter; Which of the following statements correctly assigns the character Z to the variable? Select one: a. letter = (Z); b. letter = 'Z'; Correct c. letter = "Z"; d. letter = Z;

b. letter = 'Z';

When a variable is assigned a number that is too large for its data type, it: Select one: a. underflows b. overflows c. reverses polarity d. exceeds expectations e. None of these

b. overflows

Which statement is equivalent to the following? x=x*2; Select one: a. x * 2; b. x *= 2; c. x = x * x; d. None of these

b. x *= 2;

What will the value of result be after the following statement executes? result=6-3*2+7-10/2; Select one: a. 1.5 b. 2 c. 6 d. 8

b.2

What is the value of average after the following code executes? double average; average=1.0+2.0+3.0/3.0; Select one: a. 2.0 b. 4.0 c. 6.0 d. 1.5

b.4.0

A variable whose value can be either true or false is of this data type. a. binary b. bool c. T/F d. float e. None of these

b.bool

_______ reads a line of input, including leading and embedded spaces, and stores it in a string object. Select one: a. cin.get b. getline c. cin.getline d. get e. None of these

b.getline

When a relational expression is false, it has the value ________. Select one: a. one b. zero c. zero, one, or minus one d. less than zero e. None of these

b.zero

Assuming x is 5, y is 6, and z is 8, which of the following is false? 1. x == 5; 2. 7 <= (x + 2); 3. z < = 4; 4. (1 + x) != y; 5. z >= 8; 6. x >= 0; 7. x <= (y * 2) select one: a. 3, 4, 6, 7 are false. b. Only 5 is false. c. 3 and 4 are false. d. All are false. e. None of these.

c. 3 and 4 are false.

What will the following segment of code output? score=40; if(score>95) cout<<"Congratulations!\n"; cout<<"That's a high score!\n"; cout<<"This is a test question!"<<endl; Select one: a. This is a test question! b. Congratulations! That's a high score! This is a test question! c. That's a high score! This is a test question! d. Congratulations! That's a high score! e. None of these

c. That's a high score! This is a test question!

When the final value of an expression is assigned to a variable, it will be converted to: Select one: a. The smallest C++ data type b. The largest C++ data type c. The data type of the variable d. The data type of the expression e. None of these

c. The data type of the variable

What will the following segment of code output? Assume the user enters a grade of 90 from the keyboard. cout<<"Enter a test score"<<endl; cin>>test_score; if(test_score<60); cout<<"You failed the test!"<<endl; if(test_score>60) cout<<"You passed the test!"<<endl; else cout<<"You need to study for the next test!"; Select one: a. You failed the test! b. You passed the test! c. You failed the test! You passed the test! d. You failed the test! You did poorly on the test! e. None of these

c. You failed the test! You passed the test!

Which of the following correctly consolidates the following declaration statements into one statement? int x=7; int y=16; int z=28; a. int x=7; y=16; z=28; b. int x, int y, z=7, 16, 28 c. int x=7; int y=16; int z=28; d. int x=7 y=16 z=28; e. None of these will work.

c. int x=7; int y=16; int z=28;

Assume that a program has the following string object definition: string name; Which of the following statements correctly assigns a string literal to the string object? Select one: a. name = Jane; b. name = (Jane); c. name = "Jane"; d. name = 'Jane';

c. name = "Jane";

This manipulator is used to establish a field width for the value immediately following it. Select one: a. field_width b. set_field c. setw d. iomanip e. None of these

c. setw

What is the output of the following segment of code if the value 4 is input by the user when asked to enter a number? int num; int total=0; cout<<"enter a number from 1-10:"; cin>>num; switch(num) { case1: case2: total=5; case3: total=10; case4:total=total+3; case8: total=total+6; default: total=total+4; } cout<<total<<endl; Select one: a. 0 b. 3 c. 13 d. 28 e. None of these

c.13

Which line in the following program will cause a compiler error? #include <iostream using namespace std; int main() { const int MY_VAL=77; MY_VAL=99; cout<<MY_VAL<<endl; return 0; } Select one: a. 9 b. 6 c. 7 d. 8

c.7

Relational operators allow you to ________ numbers. Select one: a. add b. multiply c. compare d. average e. None of these

c.compare

This stream manipulator forces cout to print the digits in fixed-point notation. Select one: a. setprecision(2) b. setw(2) c. fixed d. setfixed(2) e. None of these

c.fixed

This is a variable, usually a bool or an int, that signals when a condition exists. Select one: a. relational operator b. arithmetic operator c. flag d. float e. None of these

c.flag

When an if statement is placed within the conditionally-executed code of another if statement, this is known as: Select one: a. complexity b. overloading c. nesting d. validation e. None of these

c.nesting

A variable's ________ is the part of the program that has access to the variable. a. data type b. value c. scope d. reach e. None of these

c.scope

Input values should always be checked for: Select one: a. Appropriate range b. Reasonableness c. Division by zero, if division is taking place d. All of these e. None of these

d. All of these

If you intend to place a block of statements within an if statement, you must place these around the block. Select one: a. Parentheses b. Square brackets [ ] c. Angle brackets < > d. Curly braces { } e. None of these

d. Curly braces { }

What is the output of the following code segment? int x=5; if(x=2) cout<<"This is true!"<<endl; else cout<<"This is false"<<endl; cout<<"This is all folks!"<<endl; Select one: a. This is true! b. This is false! c. This is true! This is false! d. This is true! This is all folks! e. None of these

d. This is true! This is all folks!

Which character signifies the beginning of an escape sequence? a. // b. # c. { d. \ e. /

d. \

To use the rand() function, you must #include this header file in your program. Select one: a. iostream b. iomanip c. iorand d. cstdlib

d. cstdlib

When this operator is used with string operands it concatenates them, or joins them together. Select one: a. & b. * c. % d. +

d.+

Assume that x is an int variable. What value is assigned to x after the following assignment statement is executed? Select one: a. 0 b. 1 c. 2 d. —3

d.-3

What will the following code display? int x = 0, y = 1, z = 2; cout << x << y << z << endl; A) 0 1 2 B) 0 1 2 C) xyz D) 012

d.012

What is the value of number after the following statements execute? int number=10; number+=5; number-=2; number*=3; Select one: a. 15 b. 3 c. 2 d. 39

d.39

Which line in the following program will cause a compiler error? #include <iostream using namespace std; int main() { const int MY_VAL; MY_VAL=77; cout<<MY_VAL<<endl; return 0; } Select one: a. 7 b. 9 c. 8 d. 6

d.6

When using the sqrt function you must include this header file. Select one: a. iostream b. iomanip c. cstdlib d. cmath e.cstring

d.cmath

The first step in using the string class is to #include the ________ header file. Select one: a. iostream b. cctype c. cmath d. string e. None of these

d.string

In the following C++ statement, what will be executed first according to the order of precedence? result=6-3*2+7-10/2; Select one: a. 7 - 10 b. 10 / 2 c. 6 - 3 d. 2 + 7 e. 3 * 2

e. 3 * 2

Which data type typically requires only one byte of storage? a. float b. double c. short d. int e. char

e. char

This function in C++ allows you to identify how many bytes of storage on your computer system an integer data value requires. a. f(x) b. len c. int d. bytes e. sizeof

e. sizeof

True/False: Arithmetic operators that share the same precedence have right to left associativity.

false

True/False: In C++, it is impossible to display the number 34.789 in a field of 9 spaces with 2 decimal places of precision.

false

True/False: The cin << statement will stop reading input when it encounters a newline character.

false


Kaugnay na mga set ng pag-aaral

Financial Accounting Ch. 1 and 2

View Set

Delirium and Dementia, Immobility

View Set

Chapter 64 - Reproductive System

View Set

OB: Chapter 6 Disorders of the Breasts

View Set

252-EXM4-Prioritization and Delegation NCLEX Style Qs (Passpoint PrepU)

View Set

VTNE Review, med nusing final, Final, VET 112 Quiz 6, SANN, Quiz 6 Sm/lg animal, Small Animal Nursing, VET 221 - Quiz # 8, Medical Nursing, Multiple choice, Animal Nursing Final Review, VTNE - Medical Nursing, VTNE final review

View Set

Chapter 22: Nursing Management of the Postpartum Woman at Risk

View Set

Chapter 20: Caring for Clients with Upper Respiratory Disorders

View Set