2.1 Variables and assignments
What is the value stored in luckyNumber after these two statements execute?
4
Assume apples currently has the value 5 and oranges the value 9. What is the value stored in apples after the following statement?
6
Assume apples currently has the value 5 and oranges the value 9. What is the value stored in apples after the following statements?
9
Write two statements, the first setting apples to 7, and the second setting oranges to apples plus one. Terminate each statement with a semicolon.
apples=7; oranges=apples+1;
Write a statement, ending with "- 1;", that decreases the value stored in apples by 1. The output of the statement should be suppressed.
apples=apples-1;
Write a variable assignment statement that assigns birdFeeders with the current value of variable stockCount, and prints the value of the variable to the command window.
birdFeeders=stockCount
Write a variable assignment statement with assigns totalpets with 3.
totalPets=3
Write a variable assignment statement that assigns luckyNumber with 7 and suppresses the output to the command window.
luckyNumber=7;
Write a statement that assigns numCoins with numNickels + numDimes.
numCoins=numNickels + numDimes;
Write a statement that assigns myExamScore with 82. Write a statement that assigns myCurvedExamScore with myExamScore + 5.
1. % Write a statement that assigns myExamScore with 82 2. myExamScore = 82 3.% Write a statement that assigns myCurvedExamScore with myExamScore + 5 4.myCurvedExamScore = myExamScore + 5
Given a Fahrenheit value temperatureFahrenheit, write a statement that assigns temperatureCelsius with the equivalent Celsius value. While the equation is C = 5/9 * (F - 32), as an exercise use two statements, the first of which is "fractionalMultiplier = 5/9;".
1. temperatureFahrenheit=77 2. 3.% Write a statement that assigns fractionalMultiplier with 5/9 4. fractionalMultiplier=5/9 5. 6. % Modify the statement below to covert fahrenheit to celsius, 7. % assigning temperatureCelsius with the Celsius value 8. temperatureCelsius = fractionalMultiplier * (temperatureFahrenheit-32)
Given x=22 and y=99. What are x and y after the given code?
1. x is 99 and y is 99 2. x is 99 and y is 99 3. x is 99 and y is 99 4. x is 99 and y is 22