Comments

Tuesday, August 27, 2013

Write a program that count the Words in the sentence

Posted by at 3:54 AM Read our previous post


Object:
Write a program that count the Words in the sentence
Source Code:

#include <stdlib.h>
#include <iostream>
#include <stdio.h>
using namespace std;



void main()
{
      
int word=0;
char ch;

cout<<"Enter Sentence"<<endl;
while((ch = getchar()) != '\n')
{

              if (ch == ' ')
           {
                     word ++;
              }
}
      
cout<<"Counted Words : \n"<<word+1;

system("pause");

}

Output:

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Popular Posts

Labels

© Codepirate is powered by Blogger - Template designed by Stramaxon - Best SEO Template