Lecture 129
// Loop do while
#include
<iostream>
#include
<conio.h>
using
namespace std;
main ()
{
int charcnt=0;
int wordcnt=0;
char ch;
cout<<"Type in a phrase:
\n";
do
{
charcnt++;
if(ch==' ')
wordcnt++;
}while((ch=getche()) != '\r');
cout<<"\nCharacter count is
:"<<charcnt;
cout<<"\nWord count is :
"<<wordcnt;
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10