C# Programming Quiz

What planning tool was used when designing algorithms in this unit?
Flowcharts
Psuedocode
Machine Code
Breakpoints
Desk Checking
Which of the below statements will set userValue to true?
rerunProgram = null;

//Check user hasn't entered incorrect value.
if (!(rerunProgram == "Y" || rerunProgram == "N")) 
{
    Console.WriteLine("You have not typed Y or N!");
    wrongUserValue = true;
}
rerunProgram = null;

//Check user hasn't entered incorrect value.
if (rerunProgram != "Y" || rerunProgram != "N"
{
    Console.WriteLine("You have not typed Y or N!");
    wrongUserValue = true;
}
rerunProgram = null;

//Check user hasn't entered incorrect value.
if (!(rerunProgram != "Y" || rerunProgram != "N")) 
{
    Console.WriteLine("You have not typed Y or N!");
    wrongUserValue = true;
}
rerunProgram = null;

//Check user hasn't entered incorrect value.
if (rerunProgram == "Y" || rerunProgram == "N"
{
    Console.WriteLine("You have not typed Y or N!");
    wrongUserValue = true;
}
rerunProgram = null;

//Check user hasn't entered incorrect value.
if (rerunProgram == "Y" && rerunProgram == "N"
{
    Console.WriteLine("You have not typed Y or N!");
    wrongUserValue = true;
}
Select the correct IPO diagram for the following problem:

Write a program to accept a number from a user, calculate the number doubled, and return the doubled number to the user.

Input

Process

Output

double number

Prompt and get number from user

Calculate number doubled

Display doubled number

number

Input

Process

Output

Prompt and get number from user

Calculate number doubled

Display doubled number

 number

double number

Input

Process

Output

double number

Prompt and get number from user

Calculate number doubled

Display doubled number

number

Input

Process

Output

number

Prompt and get number from user

Calculate number doubled

Display doubled number

double number

Input

Process

Output

number

Prompt and get number from user

Calculate number doubled

double number

Display doubled number

 

Which of the below statements is a valid Psuedocode statement for the below problem:
 
Write a program to accept a number from a user, calculate the number doubled, and return the doubled number to the user.

static void Main(string[] args)
{
    userNumber = int.Parse(Console.ReadLine());
    doubleUserNumber = userNumber * 2;
    Console.WriteLine(doubleUserNumber);
    Console.ReadLine();
}

static void Main(string[] args)
{
    userNumber = int.Parse(Console.ReadLine());
    doubleUserNumber = userNumber * 2;
    Console.WriteLine(userNumber);
    Console.ReadLine();
}

BEGIN DOUBLE-PROGRAM

    prompt user for number

    get number from user

    calculate doubleTheNumber = number * 2

    display doubleTheNumber

END DOUBLE-PROGRAM

static void Main(string[] args)
{
    userNumber = int.Parse(Console.ReadLine());
    doubleUserNumber = userNumber * 2;
    Console.WriteLine("This is not real code. It is Psuedo Code.");
}

BEGIN DOUBLE-PROGRAM

    prompt user for number

    get number from user

    calculate doubleTheNumber = number * 2

    display user's chosen number.

END DOUBLE-PROGRAM

What is the primary purpose of a compiler in a programming language?
To convert the English-Like code used by programming languages into binary (1's and 0's) that can be understood by the computer.
To check the semantics (What to do) of the program are correct.
To check there are no syntax errors in the program before executing.
To supply syntactically correct code to the code definition window of the Integrated Development Environment being used.
To automatically fix simple errors within your code.
What is the purpose of putting the Console.ReadLine(); statement at the end of your program?
To tell the compiler there were no build errors when compiling.
To stop the program from quickly terminating after executing all lines of code and allow the user to see the output of the program.
To read the next line of input from the user at run-time.
To tell C# your program is a console program and not a Windows Forms application
To tell the user the console has just read a line of code that you inputted.
What is the difference between Psuedocode and an algorithm?
Psuedocode is a systematic logical approach used to solve problems in a computer while an Algorithm is the statement in plain English which may be translated later into a programming language (program).
An algorithm is a systematic logical approach used to solve problems in a computer while Pseudocode is used as planning comments within your program for code that you will later program.
An algorithm is a systematic logical approach used to solve problems in a computer while Pseudocode is the statement in plain English which may be translated later into a programming language (program).
An algorithm is a systematic logical approach used to solve problems in a computer while Pseudocode is code that can be used in all programming languages as it is cross-platform.
An algorithm is a systematic logical approach used to solve problems in a computer while Pseudocode is used a stub within a block of code to tell the compiler not to execute this code. 
What does a stub refer to when coding a program?
A placeholder block of code for code yet to be programmed.
A program that is coded (often through a loop) to display the image of a tree stump using ASCII characters.
A block of code that the compiler will ignore.
A stub is a somewhat casual term describing a computer network, or part of an internetwork, with no knowledge of other networks
A stub is a computer file within software applications that appears to be on disk and immediately available for use, but is actually held either in part or entirely on a different storage medium.
Programs stored in the computer's memory use which arithmetic?
Base 10 (0-10)
Base 16 (Hexadecimal)
Base 2 (0-1)
Gigabytes
Memory Maps
Based on your study of this unit, what does ASCII stand for?
Ancient Script Code for Intelegent Interpretors
Advanced Simulation And Computing Initiative Interactions
Accelerated Strategic Computing Initiative (for) information
American Standard Code For Information Interchange
A Scientific Computer Internal Intelligence
What is ASCII?
As Computers CAN only understand numbers, an ASCII code is the numerical representation of a character such as 'a' or '@' or an action of some sort.
As computers CANNOT understand numbers, an ASCII character is a character used to represent a number such as 01000001.
A super-computing program run by the National Nuclear Security Administration, in order to simulate, test, and maintain the United States nuclear stockpile.
A computer process used to process code into segment, data segment, heap, stack segment before it resides in the computers RAM.
A high level programming language that was highly popular in the 1980's.
What is a reserved word within a programming language?
A word or variable deceleration that has been used by another programmer in the past that cannot be used due to copyright.
Words such as case, catch, else, enum etc.
A word or variable that cannot be used outside of a function due to its protection level.
A variable that has already been named and cannot be renamed until re-initialised.
A word in a programming language which has a fixed meaning and cannot be redefined by the programmer or used as a variable deceleration.
What is a variable within a programming language?
A variable is a value with a set condition that cannot change once initialised or a value has been set.
A variable is a value that is not fixed and can change, depending on conditions or on information passed to the program.
A variable is a value that can change when passing information between functions or procedures.
A variable is the actual value that is being passed to the program.
A variable is a symbol for a number we do not yet know the value of.
A new programmer has created a C# Console program to allow the user to input a number and then display the number the user has input. However, he has received the below error after the user input the number 2.555.
   An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
 
Inspect the below line of code and select why this error has occurred? 
 
public static int userNumber = 0;
static void Main(string[] args)
{
    userNumber = int.Parse(Console.ReadLine());
    Console.WriteLine(userNumber);
    Console.ReadLine();
}
The program is expecting a whole number to be input by the user, but a value with a decimal has been entered instead.
The userNumber variable has not been initialised.
Input from the user is a string value and therefore cannot be used in this way to display a number value.
UserNumber is not declared.
UserNumber is trying to divide by 0 which is mathematically impossible.
Will the below code compile? Why or why not?
 
bool showFormYesNo == true;

static void Main(string[] args)
{
    if (showFormYesNo = true)
    {
        showForm();
    }
}
No. showFormYesNo is being assigned a value and therefore needs to be a single =
The if statement is a conditional statement and needs to be a double =.
No. showFormYesNo is declared outside of main and cannot be used within the method due to its protection level.
Yes. showFormYesNo is being assigned a value and correctly uses double =
The if statement is a conditional statement and correct uses single =.
No. static void Main(string[] args) should be set to static void Main(Bool[] args) to compile.
No. showForm() does not pass any arguments. It needs to pass showFormYesNo to compile.
An arithmetic operator is a mathematical function that takes two operands and performs a calculation on them. What are the arithmetic operators of C#?
+, -, *, /, %, ++, --
==, !=, >, <, >=, <=
&&, ||, !
&, |, ^
=, +=, -=, *=, /=, %=, <<=, >>=, &=, ^=, |=
What is the post-increment operator in C#?
X = x +1;
X++;
X +=1;
X = x;
X -+;
X-=1;
A relational operator is an operator that tests the relationship between two entities. What are the relational operators of c#?
+, -, *, /, %, ++, --
==, !=, >, <, >=, <=
&&, ||, !
&, |, ^
=, +=, -=, *=, /=, %=, <<=, >>=, &=, ^=, |=
What result would be output to the console from executing the following program?
 
public static int number1 = 10;
public static int number2 = 5;

static void Main(string[] args)
{
    number1 /= number2;
    Console.WriteLine(number1);
    Console.ReadLine();
}
5
10
0.5
2
15
What result would be output to the console from executing the following program?
 
public static int number1 = 7;
public static int number2 = 4;

static void Main(string[] args)
{
    number1 *= number2;
    Console.WriteLine(number1);
    Console.ReadLine();
}
28
14
7
4
1.75
What result would be output to the console from executing the following program?
 
public static int number1 = 20;
public static int number2 = 10;

static void Main(string[] args)
{
    number1 += number2;
    Console.WriteLine(number1);
    Console.ReadLine();
}
10
20
30
-30
-10
What result would be output to the console from executing the following program?
 
public static int number1 = 65;
public static int number2 = 75;

static void Main(string[] args)
{
    number1 -= number2;
    Console.WriteLine(number1);
    Console.ReadLine();
}
10
-10
65
75
-5
What result would be output to the console from executing the following program?
 
public static int number1 = 65;
public static int number2 = 75;

static void Main(string[] args)
{
    number1 = number2;
    Console.WriteLine(number1);
    Console.ReadLine();
}
65
75
10
False
-10
What is a constant?
A constant is a value with a set condition that cannot change once initialised or a value has been set.
A constant is a value that is not fixed and can change, depending on conditions or on information passed to the program.
A constant is a value that can change when passing information between functions or procedures.
A constant is the actual value that is being passed to the program.
A constant is a symbol for a number we do not yet know the value of.
Which of the below is an example of a selection statement?
switch (selectedReport) //Report user has selected.
{
    case 1:
        DisplayReport(1);
    break;

    case 2:
        DisplayReport(2);
    break;

    case 3:
        DisplayReport(3);
    break;

    case 4:
        DisplayReport(4);
    break;

    default:
        Console.WriteLine("There was an error. Reporting this to the developer.");
        ReportErrorMessage();
    break;
}
bool fileExists = false;   
for (int currentLineCount = 0; currentLineCount < 233; currentLineCount++)
{
    currentLineText = textFile.ReadLine();
    currentLineTextSplit = currentLineText.Split(",".ToCharArray());
    Console.WriteLine(currentLineTextSplit[currentLineCount]);  
}
using (var textFile = new StreamReader(@textFileLocation))
{
    textFile.ReadLine();
}
while (rerunProgram == "Y")
{
    SortReports();
    DisplayReports();
}
Which of the below is an example of an iteration statement?
bool fileExists = false;   
switch (selectedReport) //Report user has selected.
{
    case 1:
        DisplayReport(1);
    break;

    case 2:
        DisplayReport(2);
    break;

    case 3:
        DisplayReport(3);
    break;

    case 4:
        DisplayReport(4);
    break;

    default:
        Console.WriteLine("There was an error. Reporting this to the developer.");
        ReportErrorMessage();
    break;
}
for (int currentLineCount = 0; currentLineCount < 233; currentLineCount++)
{
    currentLineText = textFile.ReadLine();
    currentLineTextSplit = currentLineText.Split(",".ToCharArray());
    Console.WriteLine(currentLineTextSplit[currentLineCount]);  
}
rerunProgram = null;

//Check user hasn't entered incorrect value.
if (rerunProgram == "Y" || rerunProgram == "N"
{
    Console.WriteLine("You have not typed Y or N!");
    wrongUserValue = true;
}
using (var textFile = new StreamReader(@textFileLocation))
{
    textFile.ReadLine();
}
What is a boolean expression?
The game of bowls or marbles.
An expression that evaluates either to True or to False
A variable that can store many different data types without being expressly defined.
An integer variable that stores digits 0-9 for specific set conditions within a loop.
A true or false expression used within a method or function to optionally return a value.
What would be the output of the below Psuedocode if number was set to 10?
 
IF number > 10 THEN
    display "Larger than 10"
    IF number > 20 THEN
        display "larger than 20"
    ELSE
        display "smaller than 20"
    ENDIF
ELSE
    display "Smaller than 11"
    IF number < 0 THEN
        display "Negative number"
    ENDIF
ENDIF
Smaller than 11.
Larger than 10. Smaller than 20.
Larger than 10. Larger Than 20.
Larger Than 10. Smaller Than 11.
Negative Number.
What is a flag in programming?
A Boolean variable that is used to test if something has changed in the code.
A C# statement that tells your program to exit out of a loop or method body.
The value of a data item that is different to an expected condition within a condition statement.
A predefined endpoint of the program where code will no longer execute until the user allows the program to continue.
A piece of cloth or similar material, typically oblong or square, attachable by one edge to a pole or rope and used as the symbol or emblem of a country or institution or as a decoration during public festivities.
What is a sentinel in programming?
A Boolean variable that is used to test if something has changed in the code.
A C# statement that tells your program to exit out of a loop or method body.
The value of a data item that is different to an expected condition within a condition statement.
A predefined endpoint of the program where code will no longer execute until the user allows the program to continue.
A lookout, a person keeping watch. It's often a soldier, but not always.
What does the opening brace ‘{‘ indicate within C# Programs?
It does not mean anything
The beginning of the program
The start of a block of code
There is no code on that line.
Ignore this line of code as it is a comment.
What is the purpose of the semicolon ‘;’ in C# Programs?
It is the line continuation character. It tells the compiler that the statement continues on the next line.
It is the line terminator character. It tells the compiler that the statement has ended.
It has no real purpose. It is ignored by the compiler.
It used to prevent syntax errors.
It tells the compiler to pause on this line and wait for user input.
Programs developed within this unit have been:
Command Line Programs
Web Programs
Console Programs
Windows Form Applications
GUI Applications
How many blank lines should you place between sections of code?
3
2
0
1
4
There should be four introductory comments at the start of your program. They are:
Using, Namespace, Class, Static
System, Collection, Linq, Text
Title, Purpose, Author, Date
Title, Language, Author, Date
Version History, Author, Date, Operating System
What does this line of code do? Const char SEPARATOR_CHARACTER = ' ';
Assigns the value between the single quotes to the variable
Initialises a variable to the value between the single quotes
Creates a constant that holds a string
Creates a constant that holds the value between the single quotes
Why should a programmer use a ‘do’ loop for creating a menu?
Only a ‘do’ loop can be used for creating a menu
It always iterates at least once
It is more efficient than other loop constructs
It is easier to write
What is the difference between ReadLine() and ReadKey()?
ReadLine reads in a string up to the end of line marker whereas ReadKey reads in one character
There is no difference.
ReadLine can be used for pausing a program whereas ReadKey cannot
They are spelt differently
What is the name given to the following code: lineCounter < height
Iteration
Statement
Condition
Selection
Variable
What does it mean to say that a method is highly cohesive?
The code does not depend on code in other methods
The code is ‘sticky’ meaning that it is easy to remember
The code performs one and only one task
The code does many different tasks and so is more efficient
What is another name for the members of a struct?
Array
Record
Structure
File
What is meant by the phrase ‘input loading’?
It is a count of the number of inputs in a program
It is the loading on a program that depends on the execution speed of the program
Input data from a file into an array for later use
The extra time it takes to run a program when inputting data
The line
         return ThisMethod(value);
is contained in a method with the following header:
         public static int ThisMethod(int value)
What is the name given to this sort of method?
Recursion
Procedure
Iteration
Function
Selection
Why should a programmer use a try…catch when opening a file for reading?
The file may not be found
The try…catch is more efficient
The try…catch makes the code look professional
The programmer should not use a try…catch because the operating system will handle any file errors
What does the following code do?
StreamWriter outFile = new StreamWriter(fileName);
It opens a file for writing using the file handle ‘outFile’
It opens a file for reading using the file handle ‘outFile’
It creates an array of file names
It opens a file for appending using the file handle ‘outFile’
What is the purpose of indenting in code?
It makes code look nicer
Indents have no purpose and should not be used.
It indicates to the compiler that there is different code.
An indent is used to define methods.
Indenting is used to indicate the flow of control.
What will the value of total be after the following code is run?
 
int number = 10;
int total = 2;
 
total /= number/number;
 
12
102
0
2
1
What is a console program?
A computer game written for a game console, e.g. XBox
A computer program written for Windows.
A program that makes the user happier than another program.
A computer program designed to be used for text only interaction
A program that collects data about consoles.
If the following code is run, what values could the user enter that would require the use of a try...catch?
 
Console.WriteLine("Enter a number between 1-10");
int number = 
Convert.ToInt16(Console.ReadLine());
-1, 0, 1, 9, 10, 11
0, 99
-1, 0, 10, 11
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
'a', ' ', '', 99999999999999999999
Concatenation is the process of:
Splitting a value into segments or parts
Joining multiple values together
Creating a string array from a series of chars
Closing a file after use to prevent memory leaks and errors from occurring.
Converting a string value from lowercase to uppercase or vise versa.
Parsing is the process of:
Splitting a value into segments or parts
Joining multiple values together
Creating a string array from a series of chars
Closing a file after use to prevent memory leaks and errors from occurring.
Converting a string value from lowercase to uppercase or vise versa.
{"name":"C# Programming Quiz", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"What planning tool was used when designing algorithms in this unit?, Which of the below statements will set wrongUserValue to true?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
Powered by: Quiz Maker