wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C#-p

Total questions: 85

Worksheet time: 49mins

Name
Class
Date
1.

In C#, what would be the output of this code: int result = 5 + 2 * 3; Console.WriteLine(result);

a)

21

b)

11

c)

15

d)

10

2.

Which of the following flowchart symbols is used to indicate a decision?

a)

Terminal

b)

Process

c)

Decision

d)

Flowline

3.

You want to repeat a block of code in C# as long as a condition is true. Which loop would be best?

a)

For

b)

Do-while

c)

While

d)

Switch

4.

Given the following flowchart, what is the output if the input values for num1 = 3 and num2 = 7?

a)

3

b)

7

c)

num1

d)

num2

5.

If you input the values price = 100 and quantity = 5, what is the calculated amount based on the algorithm: Amount = price * quantity;

a)

50

b)

500

c)

105

d)

100

6.

If a triangle’s area is computed as 0.5 * base * height, what is the area for base = 10 and height = 5?

a)

15

b)

25.5

c)

50

d)

25

7.

What is the role of the ‘Process’ symbol in flowcharting?

a)

Start or stop

b)

Perform calculations

c)

Input/output

d)

Decision-making

8.

You need to compute the sum of three numbers using a flowchart. Where should the process start?

a)

After initializing values

b)

When the loop ends

c)

After inputting the values

d)

In the decision box

9.

You have a task to develop a voting software. Which flowchart symbol should you use to represent the verification step?

a)

Decision

b)

Input/Output

c)

Process

d)

Flowline

10.

Which of the following is true about a C# algorithm?

a)

Must be infinite

b)

Can be executed without an end

c)

Must have a finite number of steps

d)

Must return a float

11.

What value will be stored in ‘area’ after executing the following code? int area = 5 * 2 + 3;

a)

13

b)

16

c)

21

d)

10

12.

Which operator is used to assign a value to a variable in C#?

a)

==

b)

!=

c)

=

d)

+

13.

In a decision-making flowchart, what happens when the condition is false?

a)

It terminates

b)

The program skips to the next step

c)

It loops back

d)

It restarts

14.

Which of these is not a valid logical operator in C#?

a)

||

b)

&&

c)

&

d)

~

15.

In a flowchart representing a bank ATM withdrawal system, where would you place the "Enter PIN" process?

a)

After cash is dispensed

b)

Before a decision on account balance

c)

After printing the receipt

d)

Before inserting the ATM card

16.

Which C# data type would be most suitable for storing the result of a division operation?

a)

int

b)

char

c)

string

d)

double

17.

You are designing a flowchart for a system that determines if a student passed or failed. Where would you put the pass/fail decision?

a)

At the start

b)

In a decision box

c)

As input

d)

At the end

18.

What value will be printed by this C# code? int a = 20; int b = 4; int result = a / b; Console.WriteLine(result);

a)

5

b)

4

c)

20

d)

16

19.

In a flowchart for a shopping application, where should you place the process that calculates the total cost?

a)

After receiving user input for items and quantity

b)

Before item selection

c)

After payment is made

d)

At the end

20.

In a repetitive process, what role does the flowchart symbol “Loop” serve?

a)

End the program

b)

Repeat a sequence of steps

c)

Start the program

d)

Make a decision

21.

What does the += operator do in this code? int count = 5; count += 10;

a)

Adds 5 to 10

b)

Adds 10 to the current value of count

c)

Multiplies 5 by 10

d)

Assigns 5 to 10

22.

Which operator would you use in C# to check if two conditions are both true?

a)

||

b)

&&

c)

!

d)

==

23.

Where would you place the initialization of variables in a flowchart?

a)

After a decision is made

b)

At the start

c)

After output is printed

d)

At the end

24.

Which of the following is NOT a characteristic of a good algorithm?

a)

Finite steps

b)

Clear instructions

c)

Infinite loop

d)

Problem-solving

25.

What does the term "object-oriented" refer to in C#?

a)

A language design paradigm based on objects

b)

A type of operator

c)

A memory management technique

d)

A type of algorithm

26.

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?

a)

age > 59

b)

age >= 60

c)

age == 60

d)

age < 60

27.

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?

a)

x > 2 * y

b)

x == 2 * y

c)

x < 2 * y

d)

x >= 2 * y

28.
  1. 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?

a)

str1 > str2

b)

str1 == str2

c)

str1 < str2

d)

str1 != str2

29.

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?

a)

isRainy

b)

!isRainy

c)

isRainy == true

d)

isRainy != false

30.

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?

a)

num >= 0

b)

num == 0

c)

num < 0

d)

num > 0

31.

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?

a)

playerScore > 100

b)

playerScore >= 100

c)

playerScore == 100

d)

playerScore < 100

32.

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?

a)

price == budget

b)

price >= budget

c)

price > budget

d)

price <= budget

33.

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?

a)

userPassword != storedPassword

b)

userPassword > storedPassword

c)

userPassword == storedPassword

d)

userPassword < storedPassword

34.

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?

a)

(num % 2) == 0

b)

(num % 2) != 0

c)

(num % 2) > 0

d)

(num % 2) < 0

35.

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?

a)

age > 18 || age < 65

b)

age == 18 || age == 65

c)

age >= 18 && age <= 65

d)

age < 18 || age > 65

36.

Which of the following is the logical AND operator in C#?

a)

||

b)

!

c)

|

d)

&&

37.

In C#, which logical operator is used for logical OR?

a)

&&

b)

||

c)

!

d)

&

38.

You have two boolean variables bool isSunny = true; and bool isWarm = false;. What will be the result of the expression isSunny && isWarm?

a)

True

b)

False

c)

The code will not compile.

d)

It will throw an exception.

39.

Which of the following is the logical NOT operator in C#?

a)

!!

b)

!

c)

!=

d)

&&

40.

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?

a)

age > 18 || age < 65

b)

age < 18 && age > 65

c)

age >= 18 && age <= 65

d)

age <= 18 || age >= 65

41.

In C#, you have two boolean values bool a = true; and bool b = false;. What will be the result of the expression a || b?

a)

True

b)

False

c)

The code will not compile.

d)

It will throw an exception.

42.

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?

a)

num > 10 || num < 20

b)

num > 10 ! num < 20

c)

num > 10 && num < 20

d)

num >= 10 && num <= 20

43.

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?

a)

passwordCorrect && administratorRole

b)

passwordCorrect || administratorRole

c)

!passwordCorrect || !administratorRole

d)

passwordCorrect ! administratorRole

44.

In C#, you have two boolean variables bool x = true; and bool y = true;. What will be the result of the expression x && !y?

a)

True

b)

False

c)

It will not compile.

d)

It will throw an exception.

45.

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?

a)

age < 20 && age > 20

b)

age <= 20 || age >= 20

c)

age > 20 && age < 20

d)

age >= 20

46.

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?

a)

The discount will be "Child" for a 25-year-old.

b)

The discount will be "Student" for a 25-year-old.

c)

The discount will be "None" for a 25-year-old.

d)

The code will not compile.

47.

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;?

a)

remainder = 2

b)

remainder = 3

c)

remainder = 1

d)

remainder = 4

48.

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;?

a)

totalCost = 60

b)

totalCost = 70

c)

totalCost = 80

d)

totalCost = 90

49.

In an if-else statement, what is the condition that determines which block of code will be executed?

a)

The code with the highest indentation level

b)

The condition specified after the if keyword

c)

The condition specified after the else keyword

d)

The condition specified after the switch keyword

50.

What is the purpose of the else block in an if-else statement?

a)

To specify an alternate condition to check

b)

To provide a default action if the if condition is false

c)

To specify an additional condition to check in addition to the if condition

d)

To terminate the program

51.

a)

Start/End

b)

Process

c)

Arrows

d)

Decision/Choices

e)

Input/Output

52.

a)

Start/End

b)

Process

c)

Arrows

d)

Decision/Choices

e)

Input/Output

53.

a)

Start/End

b)

Process

c)

Arrows

d)

Decision/Choices

e)

Input/Output

54.

a)

Start/End

b)

Process

c)

Arrows

d)

Decision/Choices

e)

Input/Output

55.
a)

Start/End

b)

Process

c)

Arrows

d)

Decision/Choices

e)

Input/Output

56.

What does the 'using System' statement allow in C#?

a)

Access to classes from the System.Collections namespace

b)

Access to classes from the System.Text namespace

c)

Access to classes from the System.IO namespace

d)

Access to classes from the System namespace

57.

What is the purpose of a namespace in C#?

a)

To organize code and act as a container for classes

b)

To define variables and methods

c)

To handle exceptions in the code

d)

To control the flow of the program

58.

Which class in C# has a WriteLine() method for outputting text?

a)

Array

b)

Math

c)

String

d)

Console

59.

What is the difference between WriteLine() and Write() methods in C#?

a)

WriteLine prints in uppercase, Write prints in lowercase

b)

WriteLine prints in bold, Write prints in italics

c)

WriteLine prints on a new line, Write prints on the same line

d)

WriteLine prints in red, Write prints in blue

60.

How are single-line comments denoted in C#?

a)

With two forward slashes (//)

b)

With a hash symbol (#)

c)

With a double forward slash (//)

d)

With a semicolon (;)

61.

What is the purpose of multi-line comments in C#?

a)

To define variables

b)

To handle exceptions

c)

To execute alternative code

d)

To explain code and make it more readable

62.

Which keyword is used to declare a constant variable in C#?

a)

const

b)

var

c)

let

d)

final

63.

What is the purpose of variables in C#?

a)

To perform mathematical operations

b)

To control the flow of the program

c)

To handle exceptions

d)

To store data values

64.

What are identifiers in C#?

a)

Data types in the language

b)

Unique names for variables

c)

Operators used in expressions

d)

Keywords reserved by the language

65.

What is the general rule for naming variables in C#?

a)

Names should be in all uppercase

b)

Names must start with a number

c)

Names can contain whitespace

d)

Names can contain letters, digits, and underscore

66.

Which data type in C# stores text values?

a)

string

b)

int

c)

double

d)

bool

67.

What is the purpose of the curly braces {} in C#?

a)

Define a new namespace

b)

Declare a constant variable

c)

Handle exceptions

d)

Mark the beginning and end of a block of code

68.

Which keyword is used to declare a class in C#?

a)

variable

b)

method

c)

namespace

d)

class

69.

What is the purpose of the equal sign = in C#?

a)

Assign values to variables

b)

Compare two values

c)

Perform addition

d)

Handle exceptions

70.

What is the correct way to declare a variable in C#?

a)

int x = 5;

b)

x = int; 5;

c)

x = 5; int;

d)

5 = x; int;

71.

What will be the value of the result after this code is executed?

(a)  

72.

What is the value of finalResult after this code runs?

(a)  

73.

Given the code below, what is the final value of num after all operations?

(a)  

74.

What will be printed to the console with the following code?

(a)  

75.

What will be the value of result in this conditional statement?

(a)  

76.

Given the following code, what will be the value of y after execution?

(a)  

77.

Given the following code, what will be the value of y after execution?

(a)  

78.

After this code runs, what will be the value of result?

(a)  

79.

What will be printed by this code?

(a)  

80.

What is the final value of z in this code block?

(a)  

81.

What is the complete name of the OIC President of Cagayan State University

(a)  

82.

Who is the current faculty regent, receding here at CSU-Gonzaga

(a)  

83.

Who is the dean of the College of Information and Computing Sciences?

(a)  

84.

Who is the Campus Executive Officer of CSU- Gonzaga

(a)  

85.

CSU Vision

(a)