2.4- Numeric expressions

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Note: This activity omits parentheses to test knowledge of precedence rules. But programmers should use parentheses to make evaluation order explicit.

1. No 2.No 3.No 4.Yes 5.Yes

Wind chill (C) is computed from the air temperature (T) and wind speed (W): C = 35.7 + 0.6T - 35.7W^0.16 + 0.43TW^0.16 Write a statement that assigns windChill (C) with the wind chill given airTemp (T) and windSpeed (W). Ex: If airTemp is 32 and windSpeed is 10, then windChill is assigned with 23.1871.

1. airTemp = 32 2. windSpeed = 10 3. 4. % Assigns windChill with the temperature felt given airTemp and windSpeed 5. windChill = 35.7 + (0.6*airTemp)- (35.7*windSpeed^0.16)+ (0.43*airTemp*windSpeed^0.16)

Write a statement that assigns finalResult with firstSample plus secondSample, divided by 3. Ex: If firstSample is 18 and secondSample is 12, finalResult is 10.

1. firstSample = 18 2. secondSample = 12 3. finalResult = 10 4. % Assign finalResult with firstSample plus secondSample, divided by 3 5.finalResult = (firstSample + secondSample)/3

A drink costs 2 dollars. A taco costs 3 dollars. Write a statement that assigns totalCost with the total meal cost given the number of drinks and tacos.

1. numDrinks = 4 % Number of drinks 2. numTacos = 6 % Number of tacos 3. 4. % assigns totalCost with the total meal cost given the number of drinks and tacos 5. totalCost = (numDrinks*2)+ (numTacos*3)

Select the expression whose parentheses enforce the compiler's evaluation order for the original expression. Note: Using such parentheses is preferable over relying on precedence rules.

1. y+ (2*z) 2. (z/2)-x 3. (x*y)*z 4. x+(y^3) 5. x+((1*(y)/2) 6. (x/2)+(y/2) 7. 41

What is val after executing the line num = 6; num = num * 2; val = num + 1;

13

What is x after executing the line x = 5; y = 9; y = x; x = y;

5

Expressions must be written on one line.

false

The following indicates the expression continues on the next line:x = a + b ..

false


संबंधित स्टडी सेट्स

( 3 ) Task Environment, General Environment, & Ethics

View Set

Lesson 3: Article 1 of the U.S Constitution

View Set

Taylor's Chapter 14: Implementing (Prep U)

View Set

Anatomy Ch. 25- The Urinary System

View Set

Energy Flow in Ecosystems & Organisms

View Set

Fundamentals of Nursing Ch. 4- NCLEX PRACTICE

View Set