Methods
Input/Output
Loops
Conditionals
General
100
What does void mean?
Void means the method doesn't return anything.
100

String line = "Look at me, I can write C# code!";
Console.WriteLine(line.ToUpper());

LOOK AT ME, I CAN WRITE C# CODE!
100
Name at least three different kinds of loops.
for
while
do-while
100

int i = 0;
if(i >= 0)
{
Console.WriteLine(i);
}

0
100
int, double, char, String, etc. are examples of what?
types
200

static void printMe(int i)
{
Console.WriteLine(i);
}

/*********************/
printMe(1);
printMe(2);

1 2
200

What method reads input from a user?

Console.ReadLine(),
Console.ReadKey()
200

boolean ShouldContinue = true;
while(ShouldContinue)
{
ShouldContinue = false;
Console.WriteLine("hi!");
}

hi!
200

int n = 6;
if(isDivisibleBy2(n))
{
Console.WriteLine("divisible by 2");
}
else if(isDivisibleBy3(n))
{
Console.WriteLine("divisible by 3");
}

divisible by 2
200

What are the things between the parentheses called?
static int Sum(int n1, int n2)

arguments or parameters to a method
300

static void printMe(int i)
{
Console.WriteLine(i);
}

/*********************/
int i = 0;
printMe(i);
i = 5;
printMe(5);

0 5
300
What type do you use to read a text file?
StreamReader
300

int i = 0;
do
{
Console.WriteLine(i);
++i;
} while(i < 3);

0
1
2
300

String movie = "Sleepy Hollow";
if(movie.Equals("sleepy hollow"))
{
Console.WriteLine("found it");
}

This space has been intentionally left blank.
300
Console, StreamReader, String, are what?
Classes
400

static void printMe(int i)
{
Console.WriteLine(i);
}

/*********************/
int n = 37;
++n;
printMe(n);

38
400

Imagine numbers.txt contains:
37
25
-2
54

What does the following code print out?

StreamReader sr = new StreamReader("numbers.txt");
while(sr.EndOfStream == false)
{
Console.WriteLine( sr.ReadLine() );
}

37 25 -2 54
400

int i = 3;
do
{
Console.WriteLine(i);
--i;
} while(i > 0);

3
2
1
400

String movie = "Terminator";
if(movie.Equals("Terminator") && movie.Contains("Term"))
{
Console.WriteLine("found it");
}

found it
400

What are lines of code that begin with // called?

e.g.,
// what are these called?

comments
500

static int Sum(int n1, int n2)
{
return n1 + n2;
}

/*************************/
int x = Sum(2, 3) + Sum(1, 2);
Console.WriteLine(x);

8
500

Imagine numbers.txt contains:
2
5
0
-5
-2

What does the following code print out?

int sum = 0;
StreamReader sr = new StreamReader("numbers.txt");
while(sr.EndOfStream == false)
{
sum += int.Parse( sr.ReadLine() );
}
Console.WriteLine(sum);

0
500

for(int i = 0 ; i < 5; ++i)
{
Console.WriteLine(i + 1 * 2);
}

2 3 4 5 6
500

String movie = "Lord of the Rings";
String userMovie = "lord";
if(movie.ToLower().Equals(userMovie))
{
Console.WriteLine("case 1");
}
else if(movie.Equals(userMovie))
{
Console.WriteLine("case 2");
}
else
{
Console.WriteLine("else");
}

else
500
What's the difference between running with and without a debugger?
If you run without a debugger, breakpoints are ignored.
M
e
n
u