Posted by MindBreaker 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.