This one THIS ONE

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

What will the following program display? int a=0, b=2,x=4,y=0; cout<< (a==b)<< " "; cout << (a !=b)<< " "; cout << (b<=x)<< " "; cout << (y>a)<<endl; Select one: 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. ( 0 1 1 0 )

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 these

a. ( break )

What is assigned to the variable a given the statement below with the following assumptions: x = 10, y = 7, and z, a, and b are all int variables. a= x >= y; Select one: a. 1 b. The string "x >= y" c. 0 d. 10 e. 7

a. (1 )

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)

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) input_value= input_value+10; else input_value= input_value + 15; Select one: a. 0 b. 15 c. 25 d. 10 e. 5

b. (15 )

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. )

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)

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? Select one: a. if code is equal to C cout<<"This is a check\n"<<endl; 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";)

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 )

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; Select one: a. 0 b. 1 c. 2 d. 3 e. None of these

d. (3)

when increment precedes operand, its a

pre-fix

This increments the value then uses it

pre-fixed increments

while loop is this type

pre-test

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

t (True)

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

t (True)

a while loop's body can contains multiple statements as long as its in braces

true

should you be careful using equality ops to compare floating point values

true

while loops contains expression tested for true or false value

true

may define a ________ initilization of a for loop

variable

when does eot condition rise when accessing file

when you attempt to read past the last record

if an open file command fails in program what should you do

-send an error to the user -end the program.

what 3 functions does a operating system preform when opending documents

1. assign a file to a program 2. sets pointer to first reward 3. allocates to buffer

what does || mean

OR

Name and describe the for compentents of a loop

The setup: Usually the setup involves declaring and initializing an increment variable. This generally occurs immediately before the while. The test expression: The expression within the while loop that will cause the program to either execute the loop or exit and continue on. This always occurs within the parentheses following the keyword while. The body: This is the code within the braces. The increment: This is where the increment variable is incremented. This usually occurs at the end of the body.

control structures that causes repitition

a loop

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

a. (0)

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. Nothing will be displayed. d. true

a. (false)

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 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; } Select one: a. 99 b. 1 c. 98 d. 0

b. (1)

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; Select one: a. This code will not compile. b. 20 c. 120 d. 10

b. (20)

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) } Select one: a. 10 b. 8 c. 9 d. 6

b. (8)

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

b. (b. ! )

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

b. (x <= y)

In C++ the ++ -- operator

b. add or subtracts 1 from a value

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

b.( true)

which operator is used first

before/after relation

what does & do

both parts need to be true

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

c. (&& )

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 to 10: "; cin >>num; switch(num) { case 1: case 2: total=5; case 3: total=10; case 4: total=total+3; case 8: total=total +6; default: total=total+4; } Select one: a. 0 b. 3 c. 13 d. 28 e. None of these

c. (13 )

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. )

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

c. (Relational expression)

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!)

What will the following segment of code output? Assume the user enters a grade of 90 from the keyboard. cout<< "Enter the test score: "; 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!)

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

c. (compare )

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 )

Which value can be entered to cause the following code segment to display the message: "That number is acceptable." int number; cin >> number; if (number>10 && number <100) cout << "That number is acceptable. \n"; else cout <<"That number is not acceptable.\n"; Select one: a. 100 b. 10 c. 99 d. 0 e. All of these

c.(99)

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

c.(true)

may be used to stop a loops current iteration

continue

incremented or decremented variable

counter

This operator takes an operand and reverses its truth or falsehood. Select one: a. || b. relational c. arithmetic d. ! e. None of these

d. (! )

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

d. (== )

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)

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! Incorrect 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!)

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

d. (|| )

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

e.( C++ is fun)

a while loop is limited because the counter can be only incrimented by 1

false

condition tested by a while loop must be enclosed in () and terminated by ;

false

lay not use break and continue in the same set

false

may not rest for loop, can nest other loops

false

may not use a break statement in a nested loop

false

scope of the variable declared by a for loop's initilation extends the body of a loop

false

the increment detriment can be used for math but not for relational expressions

false

this increases a value by one

incriment

when something in a while loop must eventually become false but doesnt

infinate loop

a for statement contains 3

initialization test and update

in a for statement, this is done only once

initilization

a loop inside another is a ______ loop

nested

is Default Section in a switch required?

no

Placing a semicolon after a test expresses a

null statement

statements in a body of while may never be executes, while others atleast...

once

a do-while loop is a _____________ loop

post test

The while loop had 2 parts expression and blank

statement of block thats required

indentation is a rule or a style

style

True/False: Both of the following if statements perform the same operation. if (sales > 10000) commissionRate= 0.15; if (sales > 10000) commissionRate=0.15; (same line) Select one: True False

t (true )

an update expresion of a for loop can contain more than 1 expression

true

initialization may be omitted from loop if none is required

true

is an expression with any other value then 0 true

true

mult relate express cant be placed in test of for loop

true

stop a loop- use a break statment

true


Kaugnay na mga set ng pag-aaral

Sadlier Vocabulary Workshop Level F Unit 9 Synonyms and Antonyms

View Set

Consumer Behavior: Chapter 10 Review

View Set

Check your knowledge: Multiple - provider CPR/AED

View Set

Chapter 30: Procedures and Treatments Maternal Prep - U, Chapter 30: Procedures and Treatments, Chapter 30 Procedures and Treatments- peds, Chapter 37 Nursing Care of a Family When a Child Needs Diagnostic or Therapeutic Modalities, PN108 PrepU Chapt…

View Set

chapter 87, aminoglycosides: exam 5

View Set

ENG 211 Study questions and commentary

View Set