Advertisement
iamthehxc

Untitled

Jul 21st, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. int main ()
  3. {
  4.     char mystr1[]= "How are you today?";
  5.     int i;
  6.     int counter=0;
  7.    
  8.     printf("This is the string...\n");
  9.     printf("%s\n\n", mystr1);
  10.    
  11.     i=0;
  12.    
  13.     while(mystr1[i]!= '\0')
  14.       {
  15.         if (mystr1[i]=' ')
  16.          {
  17.            if ((mystr1[i+1] >= 'A' && mystr1[i+1] <= 'Z')
  18.                || (mystr1[i+1] >= 'a' && mystr1[i+1] <= 'z'))
  19.                  {
  20.                    counter++;
  21.                  }
  22.          }
  23.         i++;
  24.       }
  25.     printf("Number of words is: %d\n", counter);
  26.      
  27.     system("PAUSE");
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement