Computing Lab 1

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

What is the correct conditional statement to determine if x is between 19 and 99?

(x >19 && x < 99)

What is the opposite of ( x < 20 && x > 12)?

(x >=20 || x <= 12)

Another way to write the value 3452211903 is a. 3.452211903e09 b. 3.452211903e-09 c. 3.452211903x09 d. 3452211903e09

A: 3.452211903e09

What is the output of the following code? float value; value = 33.5; cout << value << endl; a. 33.5 b. 33 c. value d. garbage

A: 33.5

Which of the following lines correctly reads a value from the keyboard and stores it in the variable named myFloat? a. cin > > myFloat; b. cin << myFloat; c. cin >> "myFloat"; d. cin >> myFloat >> endl;

A: cin >> myFloat;

Which of the following is not a valid identifier? a. return b. myInt c. myInteger d. total3

A: return

Given the following code fragment, and an input value of 3, what is the output that is generated? int x; cout <<"Enter a value\n"; cin >> x; if(x=0) { cout << "x is zero\n"; } else { cout << "x is not zero\n"; } a. x is zero b. x is not zero c. unable to determine d. x is 3

A: x is zero

Given the following code fragment, what is the final value of y? int x, y; x = -1; y = 0; while(x <= 3) { y += 2; x += 1; } a. 2 b. 10 c. 6 d. 8

B: 10

19. Given the following code fragment and the input value of 2.0, what output is generated? float tax; float total; cout << "enter the cost of the item\n"; cin >> total; if ( total >= 3.0) { tax = 0.10; cout << total + (total * tax) << endl; } else { cout << total << endl; } a. 2.2 b. 2.0 c. 3.1 d. 4.4

B: 2.0

What is the value of x after the following statements? int x; x = 15/4; a. 15 b. 3 c. 4 d. 3.75

B: 3

What is the value of x after the following statements? int x; x = 0; x = x + 30; a. 0 b. 30 c. 33 d. garbage

B: 30

What is the output of the following code? cout << "This is a \\" << endl; a. This is a b. This is a \ c. nothing, it is a syntax error d. This is a \ endl

B: This is a \

If x has the value of 3, y has the value of -2, and w is 10, is the following condition true or false? if( x < 2 && w < y) a. true b. false

B: false

Executing one or more statements one or more times is known as: a. selection b. iteration c. sequence d. algorithm

B: iteration

Which of the following is a valid identifier? a. 3com b. three_com c. 3_com d. 3-com e. dollar$

B: three_com

What is the value of x after the following statement? float x; x = 3.0 / 4.0 + (3 + 2 )/ 5 a. 5.75 b. 5.75 c. 1.75 d. 3.75

C: 1.75

What is the value of x after the following statements? double x; x = 0; x += 3.0 * 4.0; x -= 2.0; a. 22.0 b. 12.0 c. 10.0 d. 14.0

C: 10.0

What is the value of x after the following statements? int x; x = 15 %4; a. 15 b. 4 c. 3 d. 3.75

C: 3

What is the value of x after the following statements? float x; x = 15/4; a. 3.75 b. 4.0 c. 3.0 d. 60

C: 3.0

Given the following code fragment, what is the output? int x=5; if( x > 5) cout << "x is bigger than 5. "; cout <<"That is all. "; cout << "Goodbye\n"; a. x is bigger than 5. That is all b. x is bigger than 5 c. That is all. Goodbye d. Goodbye

C: That is all. Goodbye

Given the following code fragment, and an input value of 5, what is the output? int x; if( x< 3) { cout << "small\n"; } else { if( x < 4) { cout << "medium\n"; } else { if( x < 6) { cout << "large\n"; } else { cout << "giant\n"; } } } a. small b. medium c. large d. giant

C: large

What is the output of the following code? float value; value = 33.5; cout << "value" << endl; a. 33.5 b. 33 c. value d. garbage

C: value

What is the correct way to write the condition y < x < z? a. (y < x < z) b. ( (y < x) && z) c. ((y > x) || (y < z)) d. ((y < x) && (x < z))

D: ((y < x) && (x < z))

What is the value of x after the following statement? float x; x = 3.0 / 4.0 + 3 + 2 / 5 a. 5.75 b. 5.75 c. 1.75 d. 3.75

D: 3.75

What is the value of x after the following statements? int x, y, z; y = 10; z = 3; x = y * z + 3; a. Garbage b. 60 c. 30 d. 33

D: 33

18. Given the following code fragment and the input value of 4.0, what output is generated? float tax; float total; cout << "enter the cost of the item\n"; cin >> total; if ( total >= 3.0) { tax = 0.10; cout << total + (total * tax) << endl; } else { cout << total << endl; } a. 3 b. 3.3 c. 4.0 d. 4.4

D: 4.4

Given the following code fragment, what is the final value of y? int x, y; x = -1; y = 0; while(x < 3) { y += 2; x += 1; } a. 2 b. 10 c. 6 d. 8

D: 8

Which of the following statements is NOT legal? a. char ch='b'; b. char ch='0'; c. char ch=65; d. char ch="cc";

D: char ch="cc";

What is the value of x after the following statements? int x; x = x + 30; a. 0 b. 30 c. 33 d. garbage

D: garbage

Given the following code fragment, which of the following expressions is always true? int x; cin >> x; a. if( x < 3) b. if( x==1) c. if( (x / 3) >1 ) d. if( x = 1)

D: if( x = 1)

What is the output of the following code fragment? int x=0; while( x < 5) cout << x << endl; x ++; cout << x << endl; a. 0 b. 5 c. 4 d. unable to determine

D: unable to determine

What is the final value of x after the following fragment of code executes? int x=0; do { x++; }while(x > 0); a. 8 b. 9 c. 10 d. 11 e. infinite loop.

E: infinite loop.

T/F: Every line in a program should have a comment.

FALSE

T/F: If x has the value of 3, y has the value of -2, and w is 10, is the following condition true of false? if(x < 2 && w < y)

FALSE

T/F: Loops are used when we need our program to make a choice between two or more things.

FALSE

T/F: The integer 0 is considered true.

FALSE

T/F: The opposite of (x >3 && x < 10) is (x < 3 && x > 10)

FALSE

T/F: The opposite of less than is greater than

FALSE

T/F: Variable names may begin with a number.

FALSE

T/F: In the following code fragment, x has the value of 3. int x = 3;

TRUE

T/F: It is legal to declare more than one variable in a single statement.

TRUE

T/F: The body of a do-while loop always executes at least once.

TRUE

T/F: The body of a while loop may never execute.

TRUE

When must we use braces to define the body of a contitional expression?

When there are multiple statements in the body.

The braces of a loop define the __________ of a loop.

body

The stream that is used for input from the keyboard is called ___________.

cin

The stream that is used for output to the screen is called ___________.

cout

A loop that always executes the loop body at least once is known as a _____________ loop.

do-while

>> is known as the stream ____________ operator.

extraction

<< is called the stream ____________________ operator.

insertion

Each time a loop body executes is known as an _______________________.

iteration

if-else statements that are inside other if-else statements are said to be _______________.

nested

Is << used for input or output?

output

In a compound logical and (&&) expression, the evaluation of the expression stops once one of the terms of the expression is false. This is known as ______________ evaluation.

short-circuit evaluation

int myValue; is called a _______________________.

variable declaration

Write the loop condition to continue a while loop as long as x is negative.

while(x < 0)


Kaugnay na mga set ng pag-aaral

ExamFx: Property and Casualty Insurance

View Set

Sociology Ch. 8: Stratification and Mobility in the United States

View Set

PSYC 100- LearningCurve 14b- Social- Cognitive Theories and the Self

View Set

3.5: The challenge of secularism

View Set

vocab workshop level h unit 4 answers

View Set

CIS 321 Data Communication and Networking Exam 2 Study Guide

View Set

Integrated Marketing Communication

View Set