MIS Quizzes
False
A defined constant number (e.g., 0.085 as tax rate) can be assigned with a new value later. True of false? True It depends... False
2 3 4
After running the following loop inside a C# program, what will be the output if the variable "number" equals 1? while (number <= 3) { Console.Write($"{++number}, "); //output in one line; } ++1 ++2 ++3 1 2 3 2 3 4 1 2 3 4
1 2 3
After running the following loop inside a C# program, what will be the output if the variable "number" equals 1? while (number <= 3) { Console.Write($"{number++} "); //output in one line; } 1++ 2++ 3++ 1 2 3 2 3 4 1 2 3 4
Three lines of "Congrats" will be shown
After running the following loop inside a C# program, what will be the output if the variable "number" equals 1? while (number <= 3) { Console.WriteLine("Congrats"); ++number; } Four lines of "Congrats" will be shown Three lines of "Congrats" will be shown Two lines of "Congrats" will be shown One line of "Congrats" will be shown
Three lines of "Congrats" will be shown
After running the following loop inside a C# program, what will be the output if the variable "number" equals 1? while (number <= 3) { Console.WriteLine("Congrats"); number++; } Four lines of "Congrats" will be shown Three lines of "Congrats" will be shown Two lines of "Congrats" will be shown Only one line of "Congrats" will be shown
{i} {i} {i}
After running the following loop inside a C# program, what will be the output? for (int i = 0; i < 3; i++) { Console.Write("{i} "); //output in one line; } 0 1 2 1 2 3 {i} {i} {i} {0} {1} {2}
0 1 2
After running the following loop inside a C# program, what will be the output? for (int i = 0; i < 3; i++) { Console.Write($"{i} "); //output in one line; } 0 1 2 1 2 3 {i} {i} {i} {0} {1} {2}
3 2 1
After running the following loop inside a C# program, what will be the output? for (int i = 3; i > 0; i--) { Console.Write($"{i} "); //output in one line; } 0 1 2 1 2 3 3 2 1 i} {i} {i}
As many as I want
How many "else if" statements can your program contain? Only 1 Up to 5 None As many as I want
True
The IF statement in general is more versatile and powerful than ternary operator. True False
False
The following DO-WHILE loop will NOT run the code in the brackets until the condition is FALSE. do { } while (true); True False
False
The following FOR-loop will stop if the "i < length" condition is met. for (int i = 0; i < length; i++) { } True False
True
The following WHILE loop will only run the code inside the brackets if the condition is true. while (true) { } True False
False
The following program is correct. string name = "John"; if (name = "John") { ...; } else { ...; } True False
False
The following program is correct: double gpa = 3.2; if (gpa <= 3.5); { ...; } else { ...; }
False
The following statement is to judge whether a score is between 60 and 80: if (score => 60 && score <= 80) True False
string MyMoney = cash.ToString();
To convert a number variable (called cash) into a string variable (called MyMoney), we should use ____ cash.ToString(); string MyMoney = cash.ToString(); string MyMoney = cash; string MyMoney = cash.ToString;
P3
What is the format specifier and precision specifier that changes a number to a percent with three decimal places? (i.e. 75.841%) P3 D3 N3 C3
20
What is the value of howManyShouldIBuy if the user enters 100? 50 40 35 30 20 int itemPrice = Convert.ToInt32(Console.ReadLine()); int howManyShouldIBuy; if (itemPrice < 10) { howManyShouldIBuy = 50; } else if (itemPrice > 10 && itemPrice <= 20) { if (itemPrice == 15) { howManyShouldIBuy = 40; } else if (itemPrice > 15) { howManyShouldIBuy = 35; } else { howManyShouldIBuy = 30; } } else { howManyShouldIBuy = 20; }
20
What is the value of howManyShouldIBuy if the user enters 10? 50 40 35 30 20 int itemPrice = Convert.ToInt32(Console.ReadLine()); int howManyShouldIBuy; if (itemPrice < 10) { howManyShouldIBuy = 50; } else if (itemPrice > 10 && itemPrice <= 20) { if (itemPrice == 15) { howManyShouldIBuy = 40; } else if (itemPrice > 15) { howManyShouldIBuy = 35; } else { howManyShouldIBuy = 30; } } else { howManyShouldIBuy = 20; }
40
What is the value of howManyShouldIBuy if the user enters 15? 50 40 35 30 20 int itemPrice = Convert.ToInt32(Console.ReadLine()); int howManyShouldIBuy; if (itemPrice < 10) { howManyShouldIBuy = 50; } else if (itemPrice > 10 && itemPrice <= 20) { if (itemPrice == 15) { howManyShouldIBuy = 40; } else if (itemPrice > 15) { howManyShouldIBuy = 35; } else { howManyShouldIBuy = 30; } } else { howManyShouldIBuy = 20; }
35
What is the value of howManyShouldIBuy if the user enters 20? 50 40 35 30 20 int itemPrice = Convert.ToInt32(Console.ReadLine()); int howManyShouldIBuy; if (itemPrice < 10) { howManyShouldIBuy = 50; } else if (itemPrice > 10 && itemPrice <= 20) { if (itemPrice == 15) { howManyShouldIBuy = 40; } else if (itemPrice > 15) { howManyShouldIBuy = 35; } else { howManyShouldIBuy = 30; } } else { howManyShouldIBuy = 20; }
string
What variable type is used to store user input from Console.ReadLine(); string int double char
float
What variable type(s) can be used to store mathematical numbers? bool float string All of the above
Console.WriteLine("How are you doing today?");
Which answer properly displays a sentence, "How are you doing today?" Console.WriteLine("How are you doing today?"); Console.writeline("How are you doing today?"); Console.Writeline(How are you doing today?); Console.WriteLine(How are you doing today?);
Console.WriteLine(pi.ToString("N2"));
Which format specifier transforms the variable (named pi) to have only two decimal places (i.e, 3.14) in the output? Console.ReadLine(pi.ToString("N2")); Console.WriteLine(pi.ToString("P4")); Console.WriteLine(pi.ToString(N3)); Console.WriteLine(pi.ToString("N2"));
int ID = 10;
Which of the following is to create a variable named ID that stores the number 10 as an integer? int ID & ID = 10; int ID = Console.ReadLine(10); string ID = "10"; int ID = 10;
string score = 10.5
Which one here is a wrong command in C#? string score = 10.5 int score = 10 You Answered string score = "10" double score = 10.5
Console.WriteLine("OU won game " + wins + " by " + Score + " points!");
double Score= 21; double wins = 7; Based on these two variables, to compose a quick headline for OU's last football game, which line correctly concatenates the variables as output? Console.WriteLine("OU won game " + wins + " by " + Score + " points!"); Console.WriteLine("OU won game " + wins + by + Score + points!); Console.WriteLine("OU won game " && Wins && " by " && score && " points!"); Console.WriteLine("OU won game " , wins , " by " , Score , " points!");
False
if (itemPrice == 15) This expression can be interpreted as "if variable itemPrice is assigned a value of 15 (then we run the following line...)". True False