Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) Given w = 13 , x = 10 , y = 26, and z = 3 , and all are declared as int ,

1) Given w = 13, x = 10, y = 26, and z = 3, and all are declared as int, what is the value of result for each line of code below? result = (x / y) * z; __________ result = w % z; __________ result = w + 5 * z; __________

a) 1.154 4 54

b) 1 8 37

c) 0 1 28

2) Choose what is stored in players when the string George Moore, Nicky Bittner, Sarah Cynthia Sylvia Stout is entered on the keyboard: string players; cout << Enter names of players << endl; cin >> players;

a) George Moore

b) George Moore, Nicky Bittner, Sarah Cynthia Sylvia Stout

c) Nothing you can't read string with cin

d) George

3) If my number is 87 and my name is Sidney Crosby what will display?

int main()

{

int playerNumber; string name; cout << Enter your player number << endl; cin >> playerNumber; cout << Enter your first and last name << endl; getline(cin, name);

cout << Hello << name << You are # << playerNumber << endl;

return 0;

}

a) Enter you first and last name

Hello Sidney Crosby You are #87

b) Enter you first and last name

Hello Sidney You are #87

c) Nothing, you need to use cin to read the name!

d) Enter you first and last name

Hello You are #87

4) Select the code which correctly implements the following logic: Read in hours worked, if hours less than or equal to forty, calculate pay as hours times rate, otherwise pay is time and one half for hours over forty

a) cout << Enter Hours worked << endl; cin >> hours; if(hours = 40) pay = hours * rate; else pay = 40 * rate + (hours 40) * rate * 1.5;

b) cout << Enter Hours worked << endl; cin >> hours; if(hours <= 40) pay = hours * rate; else pay = 40 * rate + (hours 40) * rate * 1.5;

c) cout << Enter Hours worked << endl; cin >> hours; if(hours <= 40) pay = hours * rate; else pay = hours * rate * 1.5;

d) cout << Enter Hours worked << endl; cin >> hours; pay = 40 * rate + (hours 40) * rate * 1.5;

5) What will be displayed by this program fragment? (Be careful!) int num1=0, num2=0; num1 = 14; if (num1 = 10) num2 = 2 * num1; cout << num1 << << num2 << endl;

a) 14 0

b) 0 0

c) Nothing! Syntax error.

d) 10 20

6) What will the following program display if the user enters 9: #include using namespace std; int main() { int num; cout << Enter an integer << endl; cin >> num; if (num == 12) num += 2; num *= 2; cout << num << endl; return 0; }

a) 28

b) 9

c) 12

d) 18

7) Which program fragment gets input from the keyboard and then calculates the total outside surface of a rectangular box.

a)

cout << Enter length width and height of a box << endl; cin >> length >> width >> height; surface = 2*(length * width + width * height + length * height);

b)

cout << Enter length width and height of a box << endl; cin >> length >> width >> height; surface = calculateSurface(length, width, height);

c)

cout << Enter length width and height of a box << endl; cin >> length >> width >> height; surface =length * width * height;

d)

cout << Enter length width and height of a box << endl; cin >> length >> width >> height; surface = 2*3.14159 * (length * width * height);

8) Select the correct switch statement which will display Apple, Banana, or Orange depending on whether the char variable fruit contains A, B or O. If it does not contain one of those letters, display Unknown.

a)

switch(A, B, C) { case A: cout << Apple << endl; break; case B: cout << Banana << endl; break; case O: cout << Orange << endl; break; default: cout << "Unknown" << endl; }

b)

switch(fruit) { case 1: if(fruit == 'A') cout << Apple << endl; break; case 2: if(fruit == 'B') cout << Banana << endl; break; case 3: if(fruit == 'O') cout << Orange << endl; break; default: cout << "Unknown" << endl; }

c)

switch(fruit) { case A: cout << Apple << endl; break; case B: cout << Banana << endl; break; case O: cout << Orange << endl; break; default: cout << "Unknown" << endl; }

d)

switch(fruit) { case "A": cout << Apple << endl; break; case "B": cout << Banana << endl; break; case "O": cout << Orange << endl; break; default: cout << "Unknown" << endl; }

a) if( country !=Canada || country !=Mexico )9) Which if statement below will implement the logic, all countries except Canada and Mexico are charged a 10% import duty?

{ total*=1.10; }

b) if( country !=Canada && country !=Mexico ) { total*=1.10; }

c) if( country ==Canada && country ==Mexico ) { total*=1.10; }

d)

if( country ==Canada || country ==Mexico ) { total*=1.10; }

10)

What is the value of setting after this assignment statement?

int setting; setting = (29 / 865) * 96877 * 8752235;

a) 28,426,400

b) Overflow, number too large for an int

c) 847,890,000

d) 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

b. Realize that the words you are using reveal something about you?

Answered: 1 week ago