Daily Quiz Week 1 Flashcards

1
Q

Type a C# statement that declares variable myNum as an integer and initializes it to 3.

Note: do not include any spaces before or after your answer and only include one space between the various parts of your answer. For example the following is correct:

bool isReal = true;

while the following is incorrect:

bool isReal=true; <— the problem with this statement is the number of spaces after the bool and there is no single space before and after the equals symbol.

A

int myNum = 3;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Type a C# statement that declares variable myTaxRate as a double and initializes it to 0.15

Note: Please abide by the space requirements in the first question

A

double myTaxRate = 0.15;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Type a C# statement that declares variable myGPA as a double and initializes it to 3.75

Note: Please abide by the spaces requirements in the first question

A

double myGPA = 3.75;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Type a C# statement that declares variable myAge as an integer and does not initialize it to anything.

Note: Please abide by the spaces requirements in the first question

A

int myAge;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the value of variable myNum after the following C# code is executed?

int myNum = 3;
myNum = 4;

A

4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the Hungarian notation for a text box?

A

txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the Hungarian notation for a label?

A

lbl

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the Hungarian notation for a button?

A

btn

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What should be the name of a button called Submit?

A

btnSubmit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What should be the name of a label called Name?

A

lblName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What should be the name of a text box called MPG?

A

txtMPG

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What should be the name of a label that displays an address?

A

lblAddress

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Type the line of code that assigns the text Hello to a label called result? Make sure to include one space before and after the equal symbol.

A

lblResult.Text = “Hello”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Type the line of code that assigns the words Computer Science to a label called answer? Make sure to include one space before and after the equal symbol.

A

lblAnswer.Text = “Computer Science”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the line of code that assigns the text Submit to a button called answer? Make sure to include one space before and after the equal symbol.

A

btnAnswer.Text = “Submit”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Type the line of code that assigns the string from a text box named txtUser to whole number variable num1

Include only one space before and after the equals symbol and user the Convert approach as demonstrated in the video lessons.

A

num1 = Convert.ToInt32(txtUser.Text);

17
Q

Type the line of code that assigns the string from a text box named txtTaxRate to real number variable realNum

Include only one space before and after the equals symbol and user the Convert approach as demonstrated in the video lessons.

A

realNum = Convert.ToDouble(txtTaxRate.Text);

18
Q

Type the line of code that concatenates the string variable firstName, to a space, to string variable lastName and then concatenate the C# command to go to the beginning of the next line. Assign the above to a string variable called output. For example, if firstName is Robert and lastName is Solis the output should be as follows with the cursor blinking at the beginning of the next line:

Robert Solis

Include only one space before and after the equals symbol and before and after the + symbol

A

output = firstName + “ “ + lastName + Environment.NewLine;

19
Q

Given that string variables name contains, Citrus College, address contains 1000 Foothill Blvd, city contains Glendora, state contains CA and zip contains 91741, type a single C# statement creates the address label as seen below. Assign the address label content to the string variable output

Citrus College
1000 Foothill Blvd
Note: do not include an Environment.NewLine statement after the address. Include only one space before and after the equals symbol and before and after the + symbol

A

output = name + Environment.NewLine + address;

20
Q

Type a single C# statement that simulates pressing the RETURN key twice to generate the output below. Assign everything to string variable output and do not use any variables.

Robert

Solis

Note: Include only one space before and after the equals symbol and before and after the + symbol

A

output = “Robert” + Environment.NewLine + Environment.NewLine + “Solis”;

21
Q

Type a single C# statement that assigns two separate strings (i.e., “Citrus” and “College”) to string variable result. The output should look like the following:

Citrus
College
Note: Include only one space before and after the equals symbol and before and after the + symbol

A

result = “Citrus” + Environment.NewLine + “College”;

22
Q

Type a single C# statement that assigns two separate strings (i.e., “Computer” and “Science”) to string variable major. The output should look like the following:

Computer
Science
Note: include only one space before and after the equals symbol and before and after the + symbol

A

major = “Computer” + Environment.NewLine + “Science”;

23
Q

Which of the following is the modulus operator?

A

%

24
Q

What is the result of variable remainder given the following C++ code fragment?

int userNum = 10;
int remainder = 5;
remainder = userNum % 2;

A

0

25
Q

What is the result of variable remainder given the following C++ code fragment?

int userNum = 15;
int remainder = 5;
remainder = userNum % 2;

A

1

26
Q

Any odd number mod 2 equals ______

A

1

27
Q

Any even number mod 2 equals ______

A

0