wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C# Programming Basics Quiz

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the purpose of variables in C# programming?

a)

The purpose of variables in C# programming is to handle user input.

b)

The purpose of variables in C# programming is to store and manipulate data.

c)

The purpose of variables in C# programming is to improve code readability.

d)

The purpose of variables in C# programming is to execute conditional statements.

2.

Which data type is used to store whole numbers in C#?

a)

string

b)

int

c)

float

d)

boolean

3.

What is the syntax for declaring an integer variable in C#?

a)

string myVariable;

b)

var myVariable;

c)

double myVariable;

d)

int myVariable;

4.

Which control statement is used to select only a certain part of code?

a)

for

b)

loop

c)

while

d)

if

5.

What is the output of the following code? int x = 5; int y = 3; int z = x + y; Console.WriteLine(z);

a)

2

b)

3

c)

8

d)

15

6.

Which data types are used to store decimal numbers in C#?

a)

double

b)

float

c)

integer

d)

real

7.

What is the purpose of if-else statements in C#?

a)

To declare variables in C#.

b)

To execute a block of code repeatedly.

c)

To control the flow of a program based on conditions.

d)

To handle exceptions in C#.

8.

Select the symbol for equivalence in C#

a)

>

b)

<

c)

=

d)

==

9.

What is the issue with the below code:
Console.Readline("Hello stranger");

a)

Readline

b)

Console

c)

"Hello Stranger"

d)

;

10.

Select the correct statement to find the average of three numbers

a)

average = (num1 + num2 + num3) / 3

b)

average = (num1 + num2 + num3) divide by 3

c)

average = num1 + num2 + num3 / 3

d)

average = (num1 + num2 + num3) / 4