Learning C# Part 3: Control Structures

Written By: Kevin Jordan

- 02 Sep 2006 -
















Description: This series aims to take a beginning programmer to an intermediate level in C#. Topics covered in Part 3 include: if/else statements, switch/case, and for, while, and do loops.

  1. If, Else Condition Statements
  2. Switch Statements
  3. for Loops
  4. do and while Loops
  5. Aww Man... Not Homework

Aww Man... Not Homework

So it's that time again. Here are a couple exercises to make sure you understand all the concepts in this part of the tutorial. Remember we've covered if/else, switch/case, and three different kinds of loops.

  1. Create a simple login program using the following method: use a switch statement with hard-coded usernames to see if the username is correct, then an if/else statement to test a password specific to that user.
  2. Add the ability to do exponents to your calculator from Part 2. The first field will be the base number, and you will multiply it by itself however many times it says so in the second field. Try this using both the for and while loop.

    Note: If you didn't complete the homework for Part 2, download the code at the top of this tutorial to get you started.

Once again if you have any questions then you can always reach me in the forums. Part 4 coming up...

<< Previous