functions

Upload: muhammad-ammad

Post on 09-Mar-2016

2 views

Category:

Documents


0 download

DESCRIPTION

Functions C++ Exercise

TRANSCRIPT

CHAPTER NO 06 FunctionsQNO 01.Using functions, rewrite the program developed for Programming Problem 4 in Chapter 6. The program is to determine the number of words encountered in the input stream. For the sake of simplicity, we define a word to be any sequence of characters except whitespace characters (such as blanks and newlines). Words can be separated by any number of whitespace characters. A word can be any length, from a single character to an entire line of characters. If you are writing the program to read data from a file, then it should echo print the input. For an interactive implementation, you do not need to echo print for this program.For example, for the following data, the program would indicate that 26 words were entered.This isn't exactly an example of g00d english, but it does demonstrate that a w0rd is just a se@uence of characters with0u+ any blank$. ##### ....... As with Programming Problem 4 in Chapter 6, solve this problem with two different programs: a.Use a string object into which you input each word as a string.Solution#include #include using namespace std;int WordCount(string sentence);int main(){ string Mystring; cout