Daily Quiz Week 1 Flashcards
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.
int myNum = 3;
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
double myTaxRate = 0.15;
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
double myGPA = 3.75;
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
int myAge;
What is the value of variable myNum after the following C# code is executed?
int myNum = 3;
myNum = 4;
4
What is the Hungarian notation for a text box?
txt
What is the Hungarian notation for a label?
lbl
What is the Hungarian notation for a button?
btn
What should be the name of a button called Submit?
btnSubmit
What should be the name of a label called Name?
lblName
What should be the name of a text box called MPG?
txtMPG
What should be the name of a label that displays an address?
lblAddress
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.
lblResult.Text = “Hello”;
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.
lblAnswer.Text = “Computer Science”;
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.
btnAnswer.Text = “Submit”;
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.
num1 = Convert.ToInt32(txtUser.Text);
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.
realNum = Convert.ToDouble(txtTaxRate.Text);
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
output = firstName + “ “ + lastName + Environment.NewLine;
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
output = name + Environment.NewLine + address;
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
output = “Robert” + Environment.NewLine + Environment.NewLine + “Solis”;
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
result = “Citrus” + Environment.NewLine + “College”;
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
major = “Computer” + Environment.NewLine + “Science”;
Which of the following is the modulus operator?
%
What is the result of variable remainder given the following C++ code fragment?
int userNum = 10;
int remainder = 5;
remainder = userNum % 2;
0
What is the result of variable remainder given the following C++ code fragment?
int userNum = 15;
int remainder = 5;
remainder = userNum % 2;
1
Any odd number mod 2 equals ______
1
Any even number mod 2 equals ______
0