CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
using namespace std;
int main() {
string phrase1 ;
int cont=0 ;
cout << " write a phrase : " ;
cin>> phrase1 ;
cout << phrase1 ;
phrase1 = " " + phrase1 ;
for(int i=0 ; phrase1.length()-1>i ; i++ )
{ if ( phrase1[i]==' '&& phrase1[i+1]!=' ')
cont ++ ;
}
cout<<endl<<" The amount of words are : " << cont++ ;
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run