#include <iostream.h>
#include <conio.h>
#include <stdio.h>#include <string.h>
void main()
{
char sen[50];
int word_count = 0, chr = 0, space = 0;
cout<< "\n Enter A String :";
gets(sen);
for(int i = 0; sen[i] != '\0' ; i++)
{ if (sen[i] == ' ')
space++; }
chr = strlen(sen) - space;
word_count = space + 1;
cout<< "\n The Total no. of words = " << word_count;
cout << "\n The total characters without spaces = " << chr;
getch();
}
it doesn't work if we enter more than 1 space b/w 2 words...
ReplyDelete