#include<iostream>
using namespace std;
int wordCounter(string s){
int c=0;
for(int i=0;i<s.length();i++)
if(s[i]==' ')
c++;
return c+1;
}
int main(){
string str;
cout<<"Enter string: ";
getline(cin,str);
cout <<"Number of words:
"<<wordCounter(str);
}
![1 #include<iostream> 2 using namespace std; 3. int wordCounter(string s) { int c=0; for(int i=0;i<s.length();i++) if(s[i]==](http://img.homeworklib.com/questions/8b94ee80-0eb7-11ec-924b-e7eb06fa6b90.png?x-oss-process=image/resize,w_560)
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me
using c++ program write this program without the optional exercise 3. Word Counter Write a function...
write a C++ function that accepts a pointer to a C-string as an argument and displays its contents backward. For instance, if the string argument is “ Gravity ” the function should display “ ytivarG ”. Demonstrate the function in a program that asks the user to input a string and then passes it to the function.
1. String Length Write a function that returns an integer and accepts a pointer to a C-string as an argument. The function should count the number of characters in the string and return that number. Demonstrate the function in a simple program that asks the user to input a string, passes it to the function, and then displays the function’s return value. c++
Use the jumble function to write a program jumbleguess.py that chooses a secret word from a dictionary,prints a scrambled version of the word,and then asks the user to guess the secret word. Count the number o 1.Write a function jumble (word) that returns a scrambled version of the word from (as a string) by randomly permuting its letters. 2. Use the jumble function from the previous exercise to write a program jumbleguess.py that chooses a secret word from a dictionary,...
c++ Write a function that uses recursion to raise a number to a power. The function should accept two arguments: the number to be raised and the exponent. Assume that the exponent is a nonnegative integer. Demonstrate the function in a program. Write a function that accepts an integer argument and returns the sum of all the integers from 1 up to the number passed as an argument. For example, if 50 is passed as an argument, the function will...
Write two versions of the function mostFrequentCharacter, one that accepts a C-string and one that accepts a string object, as its argument. The function should return the character that appears most frequently in the string. Demonstrate the function in a complete program. Do not use any string or cstring functions in the cstring version.
Write a program with a function that accepts a string as an argument and returns a copy of the string with the first character of each sentence capitalized. For instance, if the argument is “hello. my name is Joe. what is your name?” the function should return the string “Hello. My name is Joe. What is your name?” The program should let the user enter a string and then pass it to the function. The modified string should be displayed.
From the Tony Gaddis text, the chapter on C-String and Class String: String Length: Write a Function that passes in a C-String and using a pointer determine the number of chars in the string. Data: “This is a test string for string length” Prt String Backwards: Write a Function that passes in a C-String and prints the string backwards. Data: “This is a test string for string backwards” replaceSubstring: Write a Function that accepts three C-Strings – str1,...
In python write a module named randStr.py that has 3 functions. Each function has an optional second parameter to set a particular seed. 1) randWord accepts a string and will return a random word from that string (return value is string). 2) strMixer will randomly change words inside the string and returns a string -- If the string is only one word, then it will mix the letters of the word and return the mixed word as a string 3)...
Write a function that accepts a pointer to a C-string as its argument. The function should count the number of times the character 'w occurs in the argument and return that number.
Using Java: 1. Recursive Multiplication Write a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. Remember, multiplication can be performed as repeated addition as follows: 5×6=6+6+6+6+6 2. Recursive findings Write a recursive boolean method named reFinding. The method should search an array for a specified value, and return true if the value is found in the array, or false if the value is not found in...