اینم جواب سوال سومت ببین درست کار میکنه یا نه؟متغییر استرینگی که تعریف کردم تا 1000 کاراکتره اگه خواستی خودت تغییرش بده
اینم کد:
:31:کد:
#include <iostream.h>
#include <conio.h>
#include <string.h>
int main(){
char ch[1000];
int i,word,sentence,character;
cin.get(ch,1000);
word=sentence=character=0;
for(i=0;ch[i];i++){
if(ch[i]==' '){
word++;
character++;
}
else
if (ch[i]=='.'){
character++;
word++;
sentence++;
}
else
character++;
}
cout<<" number of characters is:"<<character<<"\n"<<"number of words is:"<<word<<
"\n"<<"number of sentences is:"<<sentence;
}