C Programming Language
2nd Edition
ISBN: 9780131103627
Author: Brian W. Kernighan, Dennis M. Ritchie, Dennis Ritchie
Publisher: Prentice Hall
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 2, Problem 4E
Write an alternate version of squeeze(s1,s2) that deletes each character in s1 that matches any character in the string s2.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Implement the following function which accepts a string as parameter and reverses it, without using any function
from the string library.
void strReverse(char *str)
Write a function that checks whether two words are anagrams. Two words are anagrams if they contain the same letters in any order. For example, “silent” and “listen” are anagrams. The header of the function is as follows:
bool isAnagram(const string& s1, const string& s2)
Write a test program that prompts the user to enter two strings and checks whether they are anagrams.
Write the following function to check whether string s1 is a substring of string s2. The function returns the first index in s2 if there is a match. Otherwise, return -1.
int indexOf(const string& s1, const string& s2)
Write a test program that reads two strings and checks whether the first string is a substring of the second string.
Chapter 2 Solutions
C Programming Language
Ch. 2 - Prob. 1ECh. 2 - Write a loop equivalent to the for loop above...Ch. 2 - Write the function htoi(s), which converts a suing...Ch. 2 - Write an alternate version of squeeze(s1,s2) that...Ch. 2 - Prob. 5ECh. 2 - Prob. 6ECh. 2 - Prob. 7ECh. 2 - Prob. 8ECh. 2 - Prob. 9ECh. 2 - Rewrite the function lower, which converts upper...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What will the following code display? int funny = 7, serious = 15; funny = serious 2; switch (funny) { case 0 ...
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Write the expression for a 5-input OR gate with inputs A 6, C, D, E, and output X
Digital Fundamentals (11th Edition)
Write a fragment of code that will compute the sum of the first n positive odd integers. For example, if n is 5...
Java: An Introduction to Problem Solving and Programming (8th Edition)
Assume the following is a constructor: ClassAct: : ClassAct(int x) { item = x; } Define a ClassAct object calle...
Starting Out with C++: Early Objects
If a class has a method named _ _str_ _ , which of these is a way to call the method? a. you call it like any o...
Starting Out with Python (3rd Edition)
In what year was Plankalkl designed? In what year was that design published?
Concepts Of Programming Languages
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a function that counts the occurrences of a specified non-overlapping string s2 in another string s1 using the following header:def count(s1, s2):For example, count("system error, syntax error", "error") returns 2. Write a test program that prompts the user to enter two strings and displays thenumber of occurrences of the second string in the first string.arrow_forwardGiven string stringVal on one line, integer idxStart on a second line, and integer choiceLen on a third line, replace choiceLen characters with "1234", starting at index idxStart. Ex: If the input is: Fuzzy bear 3 4 then the output is: Fuz1234ear Note: Using a pre-defined string function, the solution can be just one line of code. #include <iostream>#include <string>using namespace std; int main() { string stringVal; int idxStart; int choiceLen; getline(cin, stringVal); cin >> idxStart; cin >> choiceLen; /* Your code goes here */ cout << stringVal << endl; return 0;}arrow_forwardWrite a program that reads in a line consisting of a student’s name, Social Security number, user ID, and password. The program outputs the string in which all the digits of the Social Security number, and all the characters in the password are replaced by x. (The Social Security number is in the form 000- 00-0000, and the user ID and the password do not contain any spaces.) Your program should not use the operator [] to access a string element.arrow_forward
- 1. a Write a regular expression for the set of binary strings where each string has at least one pair of consecutive zeros. b. write the regular expression for the following, where sigma = (a,b): i. string of length at least 2 ii. string of length at most 2 iii. all string starting with a and ending with b iv. Even length Stringsarrow_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_forwardWrite a Boolean function called contains_whitespace() that accepts a string as a parameter and returns True if the string contains one or more whitespaces (" ", "/t", "/n") characters, or False otherwise. Write a main() function to demonstrate how it works.arrow_forward
- Write a Python code for the following: 2- for loop to find the index of substring cs'in input string?arrow_forwardWrite a function that finds the number of occurrences of a specified character in the string using the following header: int count(const string& s, char a) For example, count("Welcome", 'e') returns 2. Write a test program that reads a string and a character and displays the number of occurrences of the char- acter in the string.arrow_forwardConstruct dfas that accept the followings: a. Set of all strings on {0,1} that do not contain two consecutive 0s b. Set of all stings on {0,1} that end with two 0sarrow_forward
- Given 2 strings, return their concatenation, except remove the last character of each and swap the order of the inputted words. The strings will be at least length 3. Ex: If the input is: bird penguin the output is: pengiubir Ex: If the input is: loving csce the output is: csclovinarrow_forwardA. Which statement about regular expressions is correct? a. To find all occurrences of a matching substring for a regular expression, you must add thegflag. b. By default, pattern matching using regular expressions locates all matches in the searched string. c. To find all occurrences of a matching substring for a regular expression, you must add theiflag. d. The default behavior of a regular expression is modified by adding flags to the beginning of the expression. B. After the following JavaScript statements execute, the value ofcrayonsis["pink", "blue", "green"]. let crayons = ["pink", "purple"];crayons.shift();crayons.unshift("blue", "green"); Select one: True Falsearrow_forwardWrite a Boolean function called contains_whitespace() that accepts a string as a parameter and returns True if the string contains one or more whitespaces (" ", "/t", "/n") characters, or False otherwise. Write a main() function to demonstrate how it works. In pythonarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Computer Programming for Beginners | Functions, Parameters & Arguments | Ep24; Author: Programming With Avelx;https://www.youtube.com/watch?v=VXlh-qJpfw0;License: Standard YouTube License, CC-BY