complicated Boolean function help

Write a Boolean function IsAWord. The function takes a string as input and returns true / false. This is what the function does: If the string you give it has no spaces inside, the function returns true. If it has one or more spaces inside, the function return false. So for example, if you gave it “Barack” as input, it returns true, but if you give it “Barack Obama” as input, it returns false. Write the function body:
bool IsAWord(string S) {

Now use the function IsAWord to get N “ legal” words from the user, and returns the length of the longest legal word provided.
int LongestLegal(int N) {
int nw = 0;
int longest = 0;
return longest;

int main() {
cout << “ You will enter 5 words…”;
cout << “ Then I will tell you the length of the longest one.\n“;
int x;
x = LongestLegal(5);
cout << “Length of the longest word was length “ << x << endl;

Topic archived. No new replies allowed.