Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C# Structured, Selection and Iteration

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is a correct syntax to output "Hello World" in C#?

a)

Console.Writeline("Hello World");

b)

Console.WriteLine("Hello World");

c)

Console.WriteLine("Hello World ");

d)

Console.WriteLine("Hello World");

2.

How do you insert COMMENTS in C# code?

a)

/* This is a comment

b)

# This is a comment

c)

// This is a comment

3.

Which data type is used to create a variable that should store text?

a)

String

b)

int

c)

txt

d)

string

4.

How do you create a variable with the numeric value 5?

a)

num x = 5

b)

int x = 5;

c)

int x == 5;

d)

double x = 5;

5.

How do you create a variable with the decimal number 2.8?

a)

byte x = 2.8;

b)

double x = 2.8;

c)

int x = 2.8;

d)

int x = 2.8D;

6.

Which string handling function can be used to find the length of a string?

a)

.Length()

b)

.length();

c)

.getLength();

d)

.Length

7.

Which operator is used to add together two values?

a)

The & sign

b)

The + sign

c)

The * sign

8.

The value of a char variable can be surrounded by single quotes

a)

True

b)

False

9.

When casting you assign a value of one data type to another type

a)

True

b)

False

10.

Which operator can be used to compare two values?

a)

==

b)

=

c)

<>

d)

><

11.

How do you call a method in C#?

a)

MyMethod;

b)

MyMethod();

c)

MyMethod[];

d)

(MyMethod);

12.

How do you start writing an if statement in C#?

a)

if (x>y)

b)

if x> y:

c)

if x > y then:

13.

How do you start writing a while loop in C#?

a)

while x> y {

b)

while x > y:

c)

x > y while {

d)

while (x > y) {

14.

Which keyword is used to return a value inside a method?

a)

void

b)

break

c)

return

d)

get

15.

Which statement is used to stop a loop?

a)

exit

b)

stop

c)

return

d)

break