Answered step by step
Verified Expert Solution
Question
1 Approved Answer
. 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started