count (Wrd & Chr) with function+pointer
#include<stdio.h>
int main()
{
char A[]={"Bangladesh is The Best Team"};
char *p=A;
int character=0,word=0;
for(int i=0;A[i]!='\0';i++)
{
if((*(p+i)>='a'&&*(p+i)<='z')||(*(p+i)>='A'&&*(p+i)<='Z'))
{
character++;
}
if(((*(p+i)>='a' && *(p+i)<='z') && (*(p+i+1)==' '|| *(p+i+1)=='\0'))||((*(p+i)>='A' && *(p+i)<='Z') && (*(p+i+1)==' '|| *(p+i+1)=='\0'))){
word=word+1;
}
printf("%c",A[i]); }
printf("\n\n\ntotal character in this sentence : %d\n\n",character);
printf("\ntotal word in this sentence : %d\n\n\n",word);
}
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment