1. Variables Choose One 7 points Which one of the following choices is NOT a cor
ID: 3717350 • Letter: 1
Question
1. Variables Choose One 7 points Which one of the following choices is NOT a correct way to declare and define a variable that we have discussed in class? O string comicTitle "Spiderman" O int numOfCats 10; O decimal totalCost 4.50 O double milesDriven 350.25; 2. Assignment Operators Choose One 7 points What value would be output after the following code runs? 1 int score 5 +=5; score score-#2 score /#2 score-- 3 7 Console.WriteLine(score) O Not enough information given 3. Arrays Choose One 7 points Given the following code what value would be output? C# 2, 4, 5 }; double[ ] myArray new double()(12, 10, 2 double num1myArray[1] myArray[3]: 3num1myArray[4]; 5 Console.WriteLine(num1): 10 O 12Explanation / Answer
In order to declare decimal data type variable, we use float or double data types.
2. Answer is score: 3, below is explanation
int score = 5;
score +=5; //this statement written as score = score + 5; initially value of // score is 5, so 5 + //5 is 10.
score -=2; //this statement written as score = score - 2;
//after adding 5 score value is 10, so 10 – 2 is 8.
score /=2; //this statement written as score = score / 2
//after subtracting 2 score value is 8, so 8 / 2 is 4.
score --; //this statement written as score = score – 1
//after dividing by 2score value is 4, so 4 - 1 is 3
3. Answer is num1: 9, below is explanation
double[] myArray new double[]{12, 10, 2, 4, 5};
Above statement declare myArray of type double. In an array index start for 0(zero) and its value is rendered as ,
myArray[0] = 12
myArray[1] = 10
myArray[2] = 2
myArray[3] = 4
myArray[4] = 5
double num1 = myArray[1] + myArray[3];
Above statement rendered as num1 = 10 + 4 = 14
num1 -= myArray[4];
Above statement rendered as num1 = 14 – 5 = 9
4. Answer is num1: 0 (ZERO), below is the explanation
double num1 = 15%3;
Modulo operator returns value of reminder, so 15 / 3 remainder is 0 (ZERO)
5. Answer is You should have a frozen margarita, below is Explanation
temp = 86;
age = 29;
There are four conditions in given example:
6. Answer is X: 12, below is Explanation
While loop fails when counter value is greater than or equal to 4.
Up to 0 to 4 there are four iterations of while loops as shown below
Counter = 0, x = 0 + 3 = 3.
Counter = 1, x = 3 + 3 = 6.
Counter = 2, x = 6 + 3 = 9.
Counter = 3, x = 9 + 3 = 12.
7. Answer is This answer is false, as explained below
8. Answer is This answer is true, as explained below
9. Answer is addScore, as explained below
10. Answer is _grade and _gradeArray
11. Answer is _grade: 70
12.Answer is numExams: 5
13. Answer is examScores[3]: 100
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.