$24
NOTE:
-Please submit only C++ source files (*.cpp) through the Blackboard.
-Please put your name, project description, and date on the top of your file as a comment.
-PLEASE WORK ALONE. If cheating is found, you will get ZERO.
(Lastname_Lab8_p1.cpp, 20 points)
Write a program has a declaration in main() to store the string Vacation is near into an array named message. There should be a function call to display() that accepts message in an argument named strng and then displays the message using the pointer notation *(strng+i);
Modify the display() function written above to alter the address in message. Always use the expression *strng rather than *(strng+i) to retrieve the correct element.
(Lastname_Lab8_p2.cpp, 20 points)
Write a program to accept five integer values from keyboard. The five values will be stored in an array using a pointer. Then display the elements of the array on the screen.
Modify the program of part a) in order to display the elements of the array in reverse order using a pointer.
(Lastname_Lab8_p3.cpp, 20 points)
Write a function void reverse(char s[])that reverses a character string. For example, “Harry” becomes “yrraH”, input and output from the main function (Hint: use a pointer points to the address of each element of the character. Moreover, you know that the last element of the character array is
‘\0’).
(Lastname_Lab8_p4.cpp, 20 points)
Write a program that stores the string C plus plus is a simple programming language into an array named str. Use the declaration
str[]=”C plus plus is a simple programming language”, which ensures that the end of string escape sequence ‘\0’ is included in the array. Display the characters in the array by changing the address in a pointer called *Pt. Use a for statement in your program.
Modify the above program and make it to start the display from the first word which contains a. (Hint: display the string a simple programming language)
(Lastname_Lab8_p5.cpp, 20 points)
Write a program that declares three one dimensional arrays named miles, gallons, and mpg. Each array should be declared in main( ) and should be capable of holding ten double-
precision numbers. The numbers that should be stored in miles are 240.5, 300, 189.6, 310.6, 280.7, 206.9, 199.4, 160.3, 177.4, 192.3. The numbers should be stored in gallons are 10.3, 15.6, 8.7, 14, 16.3, 15.7, 14.9, 10.7, 8.3, 8.4. Each element of the mpg array should be calculated as the corresponding element of the miles array divided by the equivalent element of the gallons array. (e.g., mpg[0] = miles[0]/gallons[0]).
Use pointers when calculating and displaying the elements of the mpg array.