Programming Fundamentals: Arrays & Strings
Programming Fundamentals: Arrays & Strings
unique name
0 1 2 3 4
myDataArray
int myDataArray[5];
int myDataArray[5]={34,21,77,5,120};
int myDataArray[5]={34,21,77,5,120};
0 1 2 3 4
myDataArray 34 21 77 5 120
• Example:
– To store the value 75 in the third element of
myDataArray, statement would be:
myDataArray[2] = 75;
– To pass the value of the third element of
myDataArray to the variable a, we could write:
a = myDataArray[2];
char vowel[]={‘a’,’e’,’i’,’o’,’u’};
getline(text, maxLength)
• When you are done with the input just enter ‘!’
• Of course, the total number of characters are
still limited to maxLength
int myArray[5][3]={1,2,3,4,5,
6,7,8,9,10,11,12,13,14,15};
• First 3 elements go to first row, next 3 elements go to
second row and so on…