Question: . Write a C + + program that does the following: a . Create a C + + file with the name lab 1 3
Write a C program that does the following:
a Create a C file with the name labcpp
b Write the function bookEndString which has a string s and an integer r as parameters permanently
modifying the string s If the first and last letters of the string are the same, then add r copies of that letter
to the beginning and ending of the string. Otherwise, add r Zs to the beginning and ending of the string.
c Write the main function that does the following:
i Prompt the user for a string containing at least letters, validating the input until the user enters
a string with at least letters.
ii Prompt the user for a positive integer, validating the input until the user enters a positive integer.
iii. Call the function bookEndString passing into it the string and the integer.
iv Print the modified string.
Sample run of the program:
Enter a word with at least three letters: hi
Invalid input! Enter a word with at least three letters: hello
Enter a number greater than :
Invalid input! Enter a number greater than :
The modified word is: ZZZhelloZZZ
Sample run of the program:
Enter a word with at least three letters: shoes
Enter a number greater than :
The modified word is: ssssshoesssss
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
