M01ODL

Mirco Teach Session

By October 4, 2016 No Comments

Understand & Apply IF statements & While Loops

An if statement identifies which statement to run based on the value of a Boolean expression.

if (postit = 24)

{

Console.WriteLine(“Who has post-it note number 24?”);
person.raisehand();

}

(Microsoft 2016a)

Everyone in the class has a post-it numbered 1-10

IF (staffnumber == postit)

{

learner.starjump();

}

The while statement executes a statement or a block of statements until a specified expression evaluates to false.

int n = 1;

while (n < 6) {

Console.WriteLine(“Current value of n is {0}”, n);

n++;

}

(Microsoft 2016b)

You each can hopefully do a starjump,

int starjumpcounter = 0;

while (starjumpcounter <= 10) {

learner.starjump();

starjumpcounter++;

}

Microsoft, (2016a) If-Else (C# Reference) [online] available from <https://msdn.microsoft.com/en-gb/library/5011f09h.aspx> [4 October 2016]

Microsoft, (2016b) While (C# Reference) [online] available from <https://msdn.microsoft.com/en-GB/library/2aeyhxcd.aspx> [4 October 2016]

Leave a Reply