please do in c++
Q4. Using recursion only (no loops allowed!), write a C++ function of the form int count7s(int) that when passed a non-negative integer, returns the number of occurrences of the digit 7 in the number. So, for example:
count7s(717) → 2
count75(7) →1
count7s(123) → 0
Q5. Write a C++ function of the form string mirrorEnds(string)that when given a string, looks for a mirror image (backwards) string at both the beginning and end of the given string. In other words, zero or more characters at the very beginning of the given string, and at the very end of the string in reverse order (possibly overlapping). For example, the string "abXYZba" has the mirror end "ab".
mirrorEnds("abXYZba") → "ab"
mirror Ends("abca") → "a"
mirror Ends("navan") → "navan"
Q6. Write a C++ function of the form int wordsCount(string[], int, int), where the first int is the size of the string array and the second int is the length (in characters) of the strings we wish to count. So, given an array of strings, return the count of the number of strings with the given length.
wordsCount({"a", "bb", "b", "ccc"}, 4, 1) → 2
wordsCount({"a", "bb", "b", "ccc"}, 4, 3) → 1
wordsCount({"a", "bb", "b", "ccc"}, 4, 4) → 0
Q4)
CODE:
#include
using namespace std;
int count7s(int n){
if(n==0)
return 0;
if(n%10==7)
return 1+count7s(n/10);
return count7s(n/10);
}
int main(){
cout<<count7s(717)<<endl;
cout<<count7s(7)<<endl;
cout<<count7s(123)<<endl;
}
OUTPUT:

Q5)
CODE:
#include
using namespace std;
void mirrorEnds(string s){
int n=s.size();
int end=n-1,i;
for(i=0;i<n/2;i++){
if(s[i]==s[end--])
cout<<s[i];
else
return ;
}
if(i==n/2)
{
for(int j=i;j<n;j++)
{
cout<<s[j];
}
}
}
int main(){
mirrorEnds("abXYZba");
cout<<endl;
mirrorEnds("abca");
cout<<endl;
mirrorEnds("navan");
}
OUTPUT:

Q6)
CODE:;
#include
using namespace std;
int wordsCount(string s[],int n,int len){
int count=0;
for(int i=0;i< n;i++){
if(s[i].size()==len)
count++;
}
return count;
}
int main(){
string s[]={"a","bb","b","ccc"};
cout<<wordsCount(s,4,1) < < endl;
cout<<wordsCount(s,4,3) < < endl;
cout<<wordsCount(s,4,4) < < endl;
}
OUTPUT:

Using recursion only (no loops allowed!), write a C++ function of the form int count7s(int)
Write a function getScores(...) that is given a string, an int type array to fill and the max number of elements in the array as parameters and returns an integer result. The function will find each substring of the given string separated by space characters and place it in the array. The function returns the number of integers extracted. For example: int values[3]; getScores("123 456 789", values, 3 ); would return the count of 3 and fill the array with...
C++ ONLY Write a function, int flip(string a[], int n); It
reverses the order of the elements of the array and returns n. The
variable n will be greater than or equal to zero.
Example:
string array[6] = { "a", "b", "", "c", "d", "e" };
int q = flip(array, 4); // returns 4
// array now contains: "c" "" "b" "a" "d" "e"
Write a function, int flip(string a[], int n); It reverses the order of the elements of...
Write in C language
5. [8] Write a function with prototype » void string_copy(const char source[], char destination[], int n); This function copies string source to string destination. Parameter n represents the size of array destination. If the latter array is not sufficiently large to hold the whole source string then only the prefix of the string which has room in the latter array should be copied. Note that after copying, the null character should also be included to mark...
8.18 Ch 8, Part 3: Tabular Output Write this program using Eclipse. Comment and style the code according to CS 200 Style Guide. Submit the source code files (.java) below. Make sure your source files are encoded in UTF-8. Some strange compiler errors are due to the text encoding not being correct. The program you are going to write will produce a String containing a tabular representation of a 2D String array. For the 2D arrays, assume that the first...
Write a value-returning C++ function returns the average length of an array of strings. Name the function stringsAverageLength and use the following header: double stringsAverageLength(string array [], int n) { } where the parameter 'array' has 'n' strings and the return value is the average length of all of the strings in the array. For example, if the function is called like this: string cars[3] = { "Toyota", "Ford", "Tesla" }; cout << fixed << setprecision(2) << stringsAverageLength(cars, 3) <<...
#include <iostream> #include <cstring> #include <string> #include <istream> using namespace std; //Function prototypes int numVowels(char *str); int numConsonants(char *str); int main() { char string[100]; char inputChoice, choice[2]; int vowelTotal, consonantTotal; //Input a string cout << "Enter a string: " << endl; cin.getline(string, 100); do { //Displays the Menu cout << " (A) Count the number of vowels in the string"<<endl; cout << " (B) Count...
write a C program!! Q2 and Q3
Write the following functioned int search(int a[], int n, int key, int **loc); a is an array to be searched, n is the number of elements in the array, key is the search key, and loc is a pointer to the first location of the search key in array a (if found) or NULL otherwise. The function returns 1 if key is found in a, and returns 0 otherwise. Write a main() and...
please implement this function by C language
Write a string compare function which returns 1 if the strings match for n characters starting at offset m, O if the strings don't match. You must check if m is within the length of both s and t. int submatch(char* s, char* t, int n, int m)
Write a string compare function which returns 1 if the strings match for n characters starting at offset m, O if the strings don't match....
Part1. Write a C program contains the following declarations: char customer_name[N_CUSTOMERS][MAX_NAME_LENGTH]; int customer_number[N_CUSTOMERS] A program uses a text file that contains the following data on each line: The customer number is an int, and the first and last names are alphabetic strings that contain no whitespace. The last and first names themselves are however separated by whitespace. Write a C function with the following prototype: void read_customer (char name[][MAX_NAME_LENGTH], int number[], int position, FILE *cust_file) Your function should read a...
please help with this c++ function for my study guide Write the function repeatFront such that given a string and an int n, it returns a string made of the first n characters of the string, followed by the first n-1 characters of the string, and so on. You may assume that n is between 0 and the size of the string, inclusive (i.e. n >= 0 and n <= str.size()). Hint: Solve this problem by using C++ strings not...