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)
- Given a letter, created a function which returns the nearest vowel to the letter. If two vowels are equidistant to the given letter, return the earlier vowel. Examples nearest Vowel("b") - "a" nearestVowel("s") → "u" nearest Vowel ("c") → "a" nearest Vowel("i") → "i"arrow_forwardGiven a sentence, write a function that counts its number of words.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_forward
- Two 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_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_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_forward
- Complete 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_forwardplease code in python. Each problem will be placed in its own function. You will have a main function that calls the function for each problem. For these problems, you will need to use the following string functions: lower, upper, isupper, islower, isdigit, and replace, along with using [ ] to access individual characters. You may use other string functions if you find them useful. Write a function named isComplexPassword that takes a single input pa-rameter named password. This parameter will be a string. The function will look at each character in the string to determine if the password:• Is at least 8 characters long• Has at least one capital letter• Has at least one number• Has at least one symbol of !, #, or $.If the password string meets all of these requirements, the function should return True, otherwise it should return False (no direct console output). Implement this function using loops to examine each character in the string. You will need to use variables to keep track of…arrow_forward4. 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_forward
- Complete 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_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_forwardCreate a function that takes two integers, num and n, and returns an integer which is divisible by n and is the closest to num. If there are two numbers equidistant from num and divisible by n, select the larger one. Examples roundNumber (33, 25). - 25 roundNumber (46, 7)→ 49 roundNumber (133, 14) → 140arrow_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