Problem 1 --------- A. Write a function which takes a character and a character string, and returns the index of the last occurence of the character in the character string. The function should return a -1 if the character is not in the string. B. Using the function from part A, write a program which reads in a word from the terminal and prints out the letter immediately following the final 'p' in the word. If 'p' is the last letter in the word the program should indicate that. If 'p' is not in the word the program should indicate that. Example 1 ---------- Give me a word: apple The final p in apple is followed by l Example 2 --------- Give me a word: orange The word orange has no p Example 3 --------- Give me a word: plop p is the last letter in plop Answer 1 -------- int last(char c, char s[]) { int i; int pos = -1; for (i=0; s[i] != '\0'; i++) if (s[i] == c) pos = i; return pos; } void main() { char s[20]; int pos; cout << "Give me a word: "; cin >> s; pos = last('p',s); if (pos == -1) cout << "p is not in the word\n"; else if (pos == strlen(s)) cout << "p is the last letter\n"; else cout << "The last p is followed by " << s[pos+1]" } Problem 3 --------- A. Define a class called "employee" which has a first name, a last name, and a salary. B. Write a member function for employee, called "max_salary", that takes an integer as input parameter. The function should return the input integer if it is larger than the salary of the employee. Otherwise, the function should return the salary of the employee. Answer 3 -------- class employee { private: char fname[20]; char lname[20]; int salary; public: int max_salary(int x); }; int employee::max_salary(int x) { if (x > salary) return x; else return salary; } Problem 6 --------- A. What is the output of the following program? #include #include void main() { char word[10]; strcpy(word,"success"); int i; for (i = 0; word[i] != '\0'; i++) if (word[i] == 's') cout << "a"; else cout << "b"; } B. What is the output of the following program? #include #include void main() { char word[10]; strcpy(word,"success"); int i; for (i = 0; word[i] != '\0'; i++) if (word[i] == 's') cout << "a"; cout << "b"; } Answer 6 -------- A. abbbbaa B. aaab