Friday 20 March 2015

Character and Word count ingnoring Space



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<stdio.h>
int main()
{
 char A[]={"We feel proud to be a Bangladeshi"};
 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);
}

0 comments:

Post a Comment

 

Subscribe to our Newsletter

Contact our Support

Through the contact form

Our Team Memebers