InterviewSolution
Saved Bookmarks
| 1. |
Write a program to count the number of words in a sentence |
|
Answer» # include<iostream> # include<cstdio> using namespace std; int main() { int i,words=1; char str[80]; cout<<” Enter a string\n”; gets(str); for(i=0;str[i]!='\0'/;i++) if(str[i]==32) words++; cout<<"The number of words is"<<words; } |
|