Homework 22

1. Assume the following Declarations:

      int a = 10, b = 4, c = 2;
     char one = 'a';
     double d = 7.5, e = 2;
     string team = "Patriots”, h = "yes";

 Fill in the following table, giving the type and value of each expression.







one + 2



h != “yes” || team == “Broncos”



e = a / b



‘z’ – one



a / c == 5




2. Write a program that reads a target string (targetString) and a test string (testString) and tells the user whether targetString is a substring of testString.  targetString is a substring of testString means that targetString appears (in order and together!) somewhere in testString. For example: low is a substring of allowable (see it? "allowable"), but not of withhold (the letters are there, but not in order in "withhold"), nor in landowner (the letters are there and in order but not together in "landowner").


A typical run of your program should look like this:

Enter target string: act

Enter test string  : reactionary


The target act IS a substring of the test string reactionary!



Turn in

  1. A handrawn picture of the string “act” and the string “reactionary” represented as arrays of characters, complete with array indices.
  2. A printout of your program, along with a screen capture showing it run on the above example.