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)
- 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_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_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_forward
- Create 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_forwardWrite a function reverse(instring) to take a string and reverse it.arrow_forwardWe can assign a value to each character in a word based on their position in the alphabet (a = 1, b = 2, ..., z = 26). A balanced word is one where the sum of the values on the left side of the word equals the sum of the values on the right side. For odd-length words, the middle character (balance point) is ignored. Write a function that returns true if the word is balanced and false if it is not. Examples balance("zips") → true // "zips" = "zi|ps" "zips" = 26+9 | 16+19 = 35 35 = true balanced ("brake") → false // "brake" = "br|ke" = 2+18 11+5 = 2016 = false liarrow_forward
- in JSarrow_forwardDo Programming Exercise 4 from Chapter 5 using a function acronym(phrase)that returns an acronym for a phrase supplied as a string.arrow_forwardWrite a program that reads a string and outputs the number of times each lowercase vowel appears in it. Your program must contain a function with one of its parameters as a string variable, and return the number of times each lowercase vowel appears in it. Also write a program to test your function. (Note that if str is a variable of type string, then str.at(i) returns the character at the ith position. The position of the first character is 0. Also, str.length() returns the length of the str, that is, the number of characters in str.)arrow_forward
- Use R studio Let Xt be the grid (matrix). Xt(i, j) = 0, 1, 2 Write a function in R that takes a grid X and the point(i, j) and computes the number of 1.arrow_forwardWrite a function to determine the resultant force vector R of the two forces F₁ and F₂ applied to the bracket, where 0₁ (positive, unit in degree) and ₂ (negative, unit in degree). Write R in terms of unit vector along the and y axis. R must be a vector, for example R = [R₂, R₂]. Note that is expressed in degrees. The coordinate system is shown in the figure below: F2 021 return R # import numpy as np. import math from math import * # Import all the math functions from the math library from numpy import array # Complete the function given the variables F1, F2, thetal (positive, degree), theta2 (negative, degree) and return the value as array #Hints: Use numpy.array to form the force vector and then add the force vectors # Remember to convert the degree to radian in the calculations and be careful of the sign def force_vec (F1, F2, thetal, theta2): R=np.array([0,0]) # Resultant force vector, Initiation of the value # YOUR CODE HERE # Check your answer F1=300 F2=200 0₁ Theta1=60…arrow_forwardTo translate a sentence into pig Latin, create a function. When a word is written in pig Latin, its first character is dropped, shifted to the word's tail, and the letters "ay" are added. For instance, "hello world" would be "ellohay orldway" in pig Latin. Your function can be written to presume that each word has at least two letters, that there is one space between each word, and that there are no punctuation marks.arrow_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