Lecture 76
#include <iostream>
#include <conio.h>
using namespace std;
main ()
{
int charcnt=0;
int wordcnt=0;
char ch;
cout<<"Type in a phrase: \n";
for(;(ch=getche())
!= '\r';)
{
charcnt++;
if(ch==' ')
wordcnt++;
}
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