Question

In: Computer Science

Write a recursive Racket function "remove-char" that takes two string parameters, s and c, and evaluates...

Write a recursive Racket function "remove-char" that takes two string parameters, s and c, and evaluates to string s with all occurrences of c removed. The string c is guaranteed to be a length-1 string; in other words a single character string. For example (remove-char "abc" "b") should evaluate to "ac". Here is pseudocode that you could implement.

Solutions

Expert Solution

Code:

#include<stdio.h>
#include<conio.h>
#include<string.h>
char s[100],c;
int main()
{
char removal(char*,char);
printf("\n Enter the string:");
gets(s);
printf("\n Enter the character you want to remove in s :");
scanf("%c",&c);
removal(s,c);
return 0;
}

char removal(char *s,char c)
{
int i,j,length;
length=strlen(s);
for(i=0;i<length;i++)
{
if(s[i]==c)
{
for(j=i;j<length;j++)
{
s[j]=s[j+1];
}
length--;
i--;
}
}
printf("\nfinal string after Removing all occurences of c from s is %s :",s);
return 0;
}

Output:

Reference:


Related Solutions

Write a function in c++, called afterAll that takes two parameters, a vector of string and...
Write a function in c++, called afterAll that takes two parameters, a vector of string and a string. The function returns true if the 2nd parameter comes after all of the strings in the vector, order-wise, false if not. As an example, "zoo" comes after "yuzu".
Write a short recursive C++ function that determines if a string s is a palindrome, that...
Write a short recursive C++ function that determines if a string s is a palindrome, that is, it is equal to its reverse. For example,"racecar" and "gohangasalamiimalasagnahog" are palindromes. Please include the pseudo code so that I can understand better with simple English as much as possible.
Write a recursive function named multiply that takes two positive integers as parameters and returns the...
Write a recursive function named multiply that takes two positive integers as parameters and returns the product of those two numbers (the result from multiplying them together). Your program should not use multiplication - it should find the result by using only addition. To get your thinking on the right track: 7 * 4 = 7 + (7 * 3) 7 * 3 = 7 + (7 * 2) 7 * 2 = 7 + (7 * 1) 7 *...
[ Write in C, not C++] Define a function char* deleteSymbol(char *s, char x) that removes...
[ Write in C, not C++] Define a function char* deleteSymbol(char *s, char x) that removes the character x from string s. For s[] = “America”, a call to deleteSymbol(s, ‘a’) converts s[] = “Ame”
C programming Write a function called string in() that takes two string pointers as arguments. If...
C programming Write a function called string in() that takes two string pointers as arguments. If the second string is contained in the first string, have the function return the address at which the contained string begins. For instance, string in(“hats”, “at”) would return the address of the a in hats. Otherwise, have the function return the null pointer. Test the function in a complete program that uses a loop to provide input values for feeding to the function.
Write a recursive method using Java that takes a string s as input and returns a...
Write a recursive method using Java that takes a string s as input and returns a list that contains all the anagrams of the string s. An anagram is a word formed by rearranging the letters of a different word. For instance, the word ‘cat’ is an anagram of ‘act’. Notice that the output list cannot contain duplicates.
In C++ Write a function which takes two parameters: an array of ints and an int...
In C++ Write a function which takes two parameters: an array of ints and an int size of the array and prints every element greater than 5 to the screen. As an example, if the array has the following 10 elements: 2 5 8 9 7 1 0 2 6 3, your function should print out 8 9 7 6. You may assume that the parameters passed to the function are valid. Your function must have the following signature: void...
Write a function that takes a C string as an input parameter and reverses the string.
in c++ Write a function that takes a C string as an input parameter and reverses the string. The function should use two pointers, front and rear. The front pointer should initially reference the first character in the string, and the rear pointer should initially reference the last character in the string. Reverse the string by swapping the characters referenced by front and rear, then increment front to point to the next character and decrement rear to point to the...
in c++ Write a function that takes a C string as an input parameter and reverses...
in c++ Write a function that takes a C string as an input parameter and reverses the string. The function should use two pointers, front and rear. The front pointer should initially reference the first character in the string, and the rear pointer should initially reference the last character in the string. Reverse the string by swapping the characters referenced by front and rear, then increment front to point to the next character and decrement rear to point to the...
c++ Write the definition of a function named ‘isLower’ that takes as input a char value...
c++ Write the definition of a function named ‘isLower’ that takes as input a char value and returns true if the character is lowercase; otherwise, it returns false.•Print the message “The character xis lowercase” when returned value above is true, and vice versa.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT