CT243 lab2


http://geminga.it.nuigalway.ie/~gettrick/courses/CT243/labs/l2.html



  1. Consider the two functions discussed in class, Function powIT (ByVal a, ByVal, b) and Function powBINit (ByVal a, ByVal, b) that use iteration to calculate ab where b is any positive integer. Modify both of these functions so that along with the answer they also return the number of times the while loop has been executed. One way to do this is, within the function to declare an array with two elements Dim D(1) As Double . Then store the actual result (ab) in D(0) and the number of times the while loop executes in D(1), and return the whole array using Return D . Set this up using the standard simple interface of text box, command button, and click event that causes a message box to pop up with the two numbers. According to your program, how many times is the while loop in powBINit executed for
    1. 713 ?
    2. 1397 ?
    3. 144179203 ?
  2. A palindrome is a word that looks the same when spelled backwards. Examples are deed, kayak, bib. Develop a program in VB .NET to calculate whether or not a given input word is a palindrome. Your program should of course output TRUE or FALSE. Write two separate functions Function palIT(ByVal s as String) Function palREC(ByVal s as String) to do the calculation by iteration or by recursion.


© NUI, Galway