Using the f , r , and i functions from preceding exercises, write a function called r that takes three character string arguments as follows
r
and that replaces s inside source with the character string s .The function should call
the f function to locate s inside source, then call the
r function to remove s from source, and finally call the
i function to insert s into source at the proper location.
So, the function call
r
replaces the first occurrence of the character string̎ inside the character string t , if it exists, with the string ̎ . Similarly, the function call
r
has the effect of removing the first asterisk inside the t array because the replacement string is the null string.
Want to see the full answer?
Check out a sample textbook solutionChapter 9 Solutions
Programming in C
Additional Engineering Textbook Solutions
C Programming Language
Modern Database Management
Database Concepts (7th Edition)
Experiencing MIS
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Starting Out with Programming Logic and Design (4th Edition)
- Please write code as text..arrow_forwardCreate a function which replaces all the x's in the string in the following ways: 1. Replace all x's with "cks" UNLESS: 2. The word begins with "x", therefore replace it with "z". 3. The word is just the letter "x", therefore replace it with "ecks". Examples xPronounce("Inside the box was a xylophone") → "Inside the bocks was a zylophone" xPronounce ("The x ray is excellent") "The ecks ray is eckscellent" xPronounce ("OMG x box unboxing video x D") → "OMG ecks bocks unbocksing video ecks D"arrow_forwardPlease implement the function both_ends(s). Given a string s, return a string made of the first 2 and the last 2 chars of the original string, so 'employee' yields 'emee', and ’er’ yields 'erer' (since the first 2 and the last 2 chars are both 'er') However, if the string length is less than 2, return instead the empty string. The function takes a string s as its argument. Please write python codearrow_forward
- Given a sentence, write a function that counts its number of words.arrow_forwardComplete the scramble_text() function that takes a single string parameter text. The function returns a new string consisting of the characters in text scrambled order - every pair of characters have their positions swapped. You can assume that the parameter text will have a length of at least 1. For strings with an odd length, the last character remains unchanged in the scrambled text. Some examples of the function being called are shown below. For example: Test text = "I". print (f"{text} --scramble--> {scramble_text (text)}") text = "Hello" print (f"{text} --scramble--> {scramble_text (text)}") text = "superb" print (f"{text} --scramble--> {scramble_text (text)}") Result I --scramble--> I Hello --scramble--> eHllo superb --scramble--> usepbrarrow_forwardTwo words are anagrams if they are formed by rearranging the letters of another, such as cinema, formed from iceman, and vice versa. Implement an anagram checker function using string functions in C. Your program should be able to: 1. Scan for the two words to be checked 2. Pass those two words to a function called areAnagrams which returns an int to be interpreted in the main() whether the given words are anagrams or not. 3. The program should loop indefinitely until the words "EXIT NOW" is used as input. Sample Run: Enter two strings: cinema iceman cinema and iceman are anagrams! Enter two strings: almost atoms almost and atoms are NOT anagrams Enter two strings: vice versa vice and versa are NOT anagrams! Enter two strings: frail flare frail and flare are NOT anagrams! Enter two strings: algorithm logarithm algorithm and logarithm are anagrams! Enter two strings: EXIT NOWarrow_forward
- : Given a string, write a function to check if it is a permutation ofa palindrome. A palindrome is a word or phrase that is the same forwards and backwards. Apermutation is a rearrangement of letters. The palindrome does not need to be limited to justdictionary words.EXAMPLEInput: Tact CoaOutput: True (permutations: "taco cat'; "atco eta·; etc.)arrow_forwardComplete the given CPP function definition and run it for a test case. void swapString(string &str, int i, int j) { //check whether i and j are in the range //0 to str.length ()-1 and i is less than j. //if the conditions are true then swap the //characters at index i and j in the string. }arrow_forwardComplete the count_consonants () function that takes a single string parameter - text. This function counts and returns the number of consonants in the text. A consonant is an alphabetical character that is not a vowel (i.e., an alphabetical character that is not an "a", "e", "i", "o" or "u"). The function must be able to count consonants regardless of case. Some examples of the function being called are shown below. Note: • You may find the isalpha () and lower () string methods useful for this exercise. • Please only provide the function definition. For example: Test text"Hello World" print("Number of consonants ", count_consonants (text)) text "A quick brown fox" print("Number of consonants", count_consonants (text)) Result Number of consonants = 7 Number of consonants - 9arrow_forward
- 4. Complete the function show_upper. This function takes one parameter - a string (s). It should return a string made up of all the upper-case characters in s. For example, if s is “aBdDEfgHijK” then show_upper should return “BDEHK”. It should return the upper-case string - not print it. Do not change anything outside show_upper.arrow_forwardInstructions. Implement a palindrome checker using various string functions in C. Your application should be able to: 1. Scan for the word to be checked 2. Pass the word to a function called is Palindrome which retrns an int to be interpreted in the main() whether the given word is a palindrome or not. 3. The program should loop indefinitely until the word "EXIT" is usod as input. Bonus: Store cach palindrome in an array, then print all palindromes before exiting the program.arrow_forwardPlease follow all the steps givenarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningCOMPREHENSIVE MICROSOFT OFFICE 365 EXCEComputer ScienceISBN:9780357392676Author:FREUND, StevenPublisher:CENGAGE L