Introduction to C++
Jonah Warrenjonah AT parsons DOT edu
http://www.feedtank.com/2005/cpp
Lab 3
- Create a program asks the user to enter in a word. Print out the third character
in that word. Use a char array. Here is an example output:
Enter in a word: Peanuts The third character in your array is: a.
- Add to this program. After you print out the third character, now set the fifth character in the char array to a null character, and print out the character array again. It should print out the first four letters.
- Alter the program you wrote in exercise 1 to that it uses a string instead of a character array.
- Create a program that uses the following array that represent the ages of 3 people:
int age[3] = {34, 14, 56};Simply print out these three values, but do it in the following way:
Create a pointer value that points to the address of first value in this array. (p_age = &age[0];) Print out the three values by using this pointer. You will need to dereference the pointer to print the array value and then increment it to get to the next one.