Font size
WorksheetsC#-p
Total questions: 85
Worksheet time: 49mins
In C#, what would be the output of this code: int result = 5 + 2 * 3; Console.WriteLine(result);
21
11
15
10
Which of the following flowchart symbols is used to indicate a decision?
Terminal
Process
Decision
Flowline
You want to repeat a block of code in C# as long as a condition is true. Which loop would be best?
For
Do-while
While
Switch
Given the following flowchart, what is the output if the input values for num1 = 3 and num2 = 7?
3
7
num1
num2
If you input the values price = 100 and quantity = 5, what is the calculated amount based on the algorithm: Amount = price * quantity;
50
500
105
100
If a triangle’s area is computed as 0.5 * base * height, what is the area for base = 10 and height = 5?
15
25.5
50
25
What is the role of the ‘Process’ symbol in flowcharting?
Start or stop
Perform calculations
Input/output
Decision-making
You need to compute the sum of three numbers using a flowchart. Where should the process start?
After initializing values
When the loop ends
After inputting the values
In the decision box
You have a task to develop a voting software. Which flowchart symbol should you use to represent the verification step?
Decision
Input/Output
Process
Flowline
Which of the following is true about a C# algorithm?
Must be infinite
Can be executed without an end
Must have a finite number of steps
Must return a float
What value will be stored in ‘area’ after executing the following code? int area = 5 * 2 + 3;
13
16
21
10
Which operator is used to assign a value to a variable in C#?
==
!=
=
+
In a decision-making flowchart, what happens when the condition is false?
It terminates
The program skips to the next step
It loops back
It restarts
Which of these is not a valid logical operator in C#?
||
&&
&
~
In a flowchart representing a bank ATM withdrawal system, where would you place the "Enter PIN" process?
After cash is dispensed
Before a decision on account balance
After printing the receipt
Before inserting the ATM card
Which C# data type would be most suitable for storing the result of a division operation?
int
char
string
double
You are designing a flowchart for a system that determines if a student passed or failed. Where would you put the pass/fail decision?
At the start
In a decision box
As input
At the end
What value will be printed by this C# code? int a = 20; int b = 4; int result = a / b; Console.WriteLine(result);
5
4
20
16
In a flowchart for a shopping application, where should you place the process that calculates the total cost?
After receiving user input for items and quantity
Before item selection
After payment is made
At the end
In a repetitive process, what role does the flowchart symbol “Loop” serve?
End the program
Repeat a sequence of steps
Start the program
Make a decision
What does the += operator do in this code? int count = 5; count += 10;
Adds 5 to 10
Adds 10 to the current value of count
Multiplies 5 by 10
Assigns 5 to 10
Which operator would you use in C# to check if two conditions are both true?
||
&&
!
==
Where would you place the initialization of variables in a flowchart?
After a decision is made
At the start
After output is printed
At the end
Which of the following is NOT a characteristic of a good algorithm?
Finite steps
Clear instructions
Infinite loop
Problem-solving
What does the term "object-oriented" refer to in C#?
A language design paradigm based on objects
A type of operator
A memory management technique
A type of algorithm
You are writing a program to determine if a user's input int age is eligible for a senior discount (age 60 or older). Which of the following conditions would you use?
age > 59
age >= 60
age == 60
age < 60
You have two variables int x = 10; and int y = 5;. You want to check if x is greater than twice the value of y. Which of the following expressions should you use?
x > 2 * y
x == 2 * y
x < 2 * y
x >= 2 * y
You are developing a program to compare two strings string str1 and string str2. You want to check if str1 is lexicographically greater than str2. Which of the following expressions would you use?
str1 > str2
str1 == str2
str1 < str2
str1 != str2
You have a boolean variable bool isRainy = true; and want to check if it's not raining. Which of the following expressions should you use?
isRainy
!isRainy
isRainy == true
isRainy != false
You are validating user input for a positive integer int num. You want to ensure that num is greater than zero. Which of the following conditions would you use?
num >= 0
num == 0
num < 0
num > 0
In a game, you want to check if the player's score int playerScore is at least 100 points to qualify for the next level. Which of the following conditions should you use?
playerScore > 100
playerScore >= 100
playerScore == 100
playerScore < 100
You have two variables double price = 25.50; and double budget = 50.00;. You want to check if the price is within the budget. Which of the following expressions should you use?
price == budget
price >= budget
price > budget
price <= budget
You are implementing a login system and want to verify if the entered password string userPassword matches the stored password. Which of the following expressions would you use?
userPassword != storedPassword
userPassword > storedPassword
userPassword == storedPassword
userPassword < storedPassword
You are developing a program to determine if a given number int num is an odd number. Which of the following conditions would you use?
(num % 2) == 0
(num % 2) != 0
(num % 2) > 0
(num % 2) < 0
You are designing a survey and want to ensure that the user's age int age is between 18 and 65 (inclusive) to participate. Which of the following conditions should you use?
age > 18 || age < 65
age == 18 || age == 65
age >= 18 && age <= 65
age < 18 || age > 65
Which of the following is the logical AND operator in C#?
||
!
|
&&
In C#, which logical operator is used for logical OR?
&&
||
!
&
You have two boolean variables bool isSunny = true; and bool isWarm = false;. What will be the result of the expression isSunny && isWarm?
True
False
The code will not compile.
It will throw an exception.
Which of the following is the logical NOT operator in C#?
!!
!
!=
&&
You are developing a program to check if a user's input int age is outside the range of 18 to 65 (exclusive). Which logical operator(s) would you use?
age > 18 || age < 65
age < 18 && age > 65
age >= 18 && age <= 65
age <= 18 || age >= 65
In C#, you have two boolean values bool a = true; and bool b = false;. What will be the result of the expression a || b?
True
False
The code will not compile.
It will throw an exception.
You want to check if a number int num is both greater than 10 and less than 20. Which logical operator(s) would you use?
num > 10 || num < 20
num > 10 ! num < 20
num > 10 && num < 20
num >= 10 && num <= 20
You are implementing a login system and want to grant access if either the user's password is correct or they have an administrator role. Which logical operator(s) would you use?
passwordCorrect && administratorRole
passwordCorrect || administratorRole
!passwordCorrect || !administratorRole
passwordCorrect ! administratorRole
In C#, you have two boolean variables bool x = true; and bool y = true;. What will be the result of the expression x && !y?
True
False
It will not compile.
It will throw an exception.
You have a list of students' ages, and you want to find the students who are not teenagers (age 20 or above). Which logical operator(s) would you use?
age < 20 && age > 20
age <= 20 || age >= 20
age > 20 && age < 20
age >= 20
You are creating a program to check if a user's input int age is eligible for various discounts. If the age is 5 or younger, the discount is "Child"; if the age is between 6 and 17, the discount is "Student"; otherwise, there is no discount ("None"). What discount would a 25-year-old receive?
The discount will be "Child" for a 25-year-old.
The discount will be "Student" for a 25-year-old.
The discount will be "None" for a 25-year-old.
The code will not compile.
You are developing a program to calculate the remainder of a division operation. The user inputs 17 as the dividend and 5 as the divisor. What would be the result of the expression remainder = dividend % divisor;?
remainder = 2
remainder = 3
remainder = 1
remainder = 4
You are developing a program to calculate the total cost of items in a shopping cart. You have the prices of three items: $10, $20, and $30. What would be the result of the expression totalCost = item1Price + item2Price + item3Price;?
totalCost = 60
totalCost = 70
totalCost = 80
totalCost = 90
In an if-else statement, what is the condition that determines which block of code will be executed?
The code with the highest indentation level
The condition specified after the if keyword
The condition specified after the else keyword
The condition specified after the switch keyword
What is the purpose of the else block in an if-else statement?
To specify an alternate condition to check
To provide a default action if the if condition is false
To specify an additional condition to check in addition to the if condition
To terminate the program
Start/End
Process
Arrows
Decision/Choices
Input/Output
Start/End
Process
Arrows
Decision/Choices
Input/Output
Start/End
Process
Arrows
Decision/Choices
Input/Output
Start/End
Process
Arrows
Decision/Choices
Input/Output
Start/End
Process
Arrows
Decision/Choices
Input/Output
What does the 'using System' statement allow in C#?
Access to classes from the System.Collections namespace
Access to classes from the System.Text namespace
Access to classes from the System.IO namespace
Access to classes from the System namespace
What is the purpose of a namespace in C#?
To organize code and act as a container for classes
To define variables and methods
To handle exceptions in the code
To control the flow of the program
Which class in C# has a WriteLine() method for outputting text?
Array
Math
String
Console
What is the difference between WriteLine() and Write() methods in C#?
WriteLine prints in uppercase, Write prints in lowercase
WriteLine prints in bold, Write prints in italics
WriteLine prints on a new line, Write prints on the same line
WriteLine prints in red, Write prints in blue
How are single-line comments denoted in C#?
With two forward slashes (//)
With a hash symbol (#)
With a double forward slash (//)
With a semicolon (;)
What is the purpose of multi-line comments in C#?
To define variables
To handle exceptions
To execute alternative code
To explain code and make it more readable
Which keyword is used to declare a constant variable in C#?
const
var
let
final
What is the purpose of variables in C#?
To perform mathematical operations
To control the flow of the program
To handle exceptions
To store data values
What are identifiers in C#?
Data types in the language
Unique names for variables
Operators used in expressions
Keywords reserved by the language
What is the general rule for naming variables in C#?
Names should be in all uppercase
Names must start with a number
Names can contain whitespace
Names can contain letters, digits, and underscore
Which data type in C# stores text values?
string
int
double
bool
What is the purpose of the curly braces {} in C#?
Define a new namespace
Declare a constant variable
Handle exceptions
Mark the beginning and end of a block of code
Which keyword is used to declare a class in C#?
variable
method
namespace
class
What is the purpose of the equal sign = in C#?
Assign values to variables
Compare two values
Perform addition
Handle exceptions
What is the correct way to declare a variable in C#?
int x = 5;
x = int; 5;
x = 5; int;
5 = x; int;
What will be the value of the result after this code is executed?
(a)
What is the value of finalResult after this code runs?
(a)
Given the code below, what is the final value of num after all operations?
(a)
What will be printed to the console with the following code?
(a)
What will be the value of result in this conditional statement?
(a)
Given the following code, what will be the value of y after execution?
(a)
Given the following code, what will be the value of y after execution?
(a)
After this code runs, what will be the value of result?
(a)
What will be printed by this code?
(a)
What is the final value of z in this code block?
(a)
What is the complete name of the OIC President of Cagayan State University
(a)
Who is the current faculty regent, receding here at CSU-Gonzaga
(a)
Who is the dean of the College of Information and Computing Sciences?
(a)
Who is the Campus Executive Officer of CSU- Gonzaga
(a)
CSU Vision
(a)
