Array Review

 

 

1. Given the following declaration:

 

                        int nums [3] [2];

Draw a diagram of nums showing the number of rows and columns.  Draw the picture of the filled in array after the following code executes.

 

 

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

          for (int j = 0; j < 2; j++)

              nums [i] [j] = i  * 10;

 

2.     

              i.    Declare a two dimensional double array that has 6 rows and 2 columns.

 

            ii.    Draw a picture of the array. 

 

           iii.    How many bytes does this array take up?

 

           iv.    Write the code that fills up the even numbered rows with 0, and the odd numbered rows with 1.

 

3.      Given the declarations:

 

char  junkInfo[18] = ”misinformation”;

char  punctuation[7];

 

 

a)      What is the value of junkInfo[3]?

b)      What is the value of strcmp(message,”information)?

c)      After the statement strcpy(punctuation,”!!::;”), what is in punctuation[2]?

d)   Suppose that you do not know the contents of junkInfo.  Give the C++ code that will print out “YES” if there are any vowels (a,e,i,o,u) in junkInfo.