Services 1. Click here to edit me

 

I'm a paragraph. Click here to add your own text and edit me. It’s easy. Just click “Edit Text” or double click me to add your own content and make changes to the font. Feel free to drag and drop me anywhere you like on your page. I’m a great place for you to tell a story and let your users know a little more about you.

This is a great space to write long text about your company and your services. You can use this space to go into a little more detail about your company. Talk about your team and what services you provide. Tell your visitors the story of how you came up with the idea for your business and what makes you different from your competitors. Make your company stand out and show your visitors who you are. Tip: Add your own image by double clicking the image and clicking Change Image.

Services 2. Click here to edit me

 

I'm a paragraph. Click here to add your own text and edit me. It’s easy. Just click “Edit Text” or double click me to add your own content and make changes to the font. Feel free to drag and drop me anywhere you like on your page. I’m a great place for you to tell a story and let your users know a little more about you.

This is a great space to write long text about your company and your services. You can use this space to go into a little more detail about your company. Talk about your team and what services you provide. Tell your visitors the story of how you came up with the idea for your business and what makes you different from your competitors. Make your company stand out and show your visitors who you are. Tip: Add your own image by double clicking the image and clicking Change Image.

Programming Tutorial in C# - Lab session 2

 

In this second session, we will expore variabes in a little more detail, to recap a variable definition is:

 

"In computer programming, a variable or scalar is a storage location paired with an associated symbolic name (an identifier), which contains some known or unknown quantity or information referred to as a value. "

 

Consider the example:

 

int myVariable = 0;

 

This declares a variable of data type int that is named myVariable with a value of 0.

 

 

Lab session 2) variables and loops

 

Create a new console project in Visual Studio, inside the main function, see below, please type in the following;

 

       static void Main(string[] args)
        {

         

                  // initilise the variable to 0, this variable is an integer - int for short.

                  int myVariable = 0;

 

                 // basic for loop iterating through ten iterations.

                 for (int i = 0; i < 10; i++)

                 {

                            myVariable = i; // assign the variable the new value.

 

                           If( myVariable % 2 == 0  ) {

                                     // output the value of the variable.

                                     Console.WriteLine("the value of myVariable is now " + myVariable.ToString());

                           }

                           else

                           {

                                     // output the value of the variable.

                                     Console.WriteLine("the value of myVariable is not divisible by 2");

                           }

                  }


        }

 

Notice the line,

 

for (int i = 0; i < 10; i++)

 

This is a standard for loop, that is anything within the curly brackets is repeated n times, where n time is dependent on the expression, that is variable i is assigned the value of 0, while is is less then 10, the i++ statement increments the variable by 1 for each loop.

 

Before you run the program, what do you expect it to output?

 

After you have run the program, please modifty the program to do the following (help will be provided).

 

1) instead of ten loops, modifiy to 20 loops.

2) change the output to only show if the number is divisible by 2.

 

Clue:

 

 

 

By the time you have understood this, we will be deeper software developement :)

 

M

 

 

 

 

                 
            

 

 

Services 3. Click to edit me

 

I'm a paragraph. Click here to add your own text and edit me. It’s easy. Just click “Edit Text” or double click me to add your own content and make changes to the font. Feel free to drag and drop me anywhere you like on your page. I’m a great place for you to tell a story and let your users know a little more about you.

This is a great space to write long text about your company and your services. You can use this space to go into a little more detail about your company. Talk about your team and what services you provide. Tell your visitors the story of how you came up with the idea for your business and what makes you different from your competitors. Make your company stand out and show your visitors who you are. Tip: Add your own image by double clicking the image and clicking Change Image.