Advertisement
iamaamir

Word, Vowels, Constant and char Counter

Aug 21st, 2014
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main () {
  4.    
  5.     int nv,nc,nw,ns,nchar,i;   
  6.     nv=nc=nw=ns=nchar=0;
  7.     char c[50];
  8.     puts("Enter any String");
  9.     gets(c);
  10.        
  11.         for(i=0;c[i]!='\0';i++){
  12.            
  13.             if( c[i]=='a'||
  14.                 c[i]=='e'||
  15.                 c[i]=='i'||
  16.                 c[i]=='o'||
  17.                 c[i]=='u'||
  18.                 c[i]=='A'||
  19.                 c[i]=='E'||
  20.                 c[i]=='I'||
  21.                 c[i]=='O'||
  22.                 c[i]=='U'
  23.               )
  24.               {
  25.                 nv++;
  26.               }
  27.             else if (c[i]==' '){
  28.                 ns++;
  29.             }
  30.             else if (c[i]>=65 && c[i]<=90 ||
  31.                      c[i]>=97 && c[i]<=122
  32.                     ){
  33.                 nc++;
  34.             }
  35.             nchar = nv+nc;
  36.             nw = ns+1;
  37.         }
  38.         if (strlen(c)>50){
  39.             system("cls");
  40.             puts("String was Too Large Only 50 Charecters Allowed");
  41.         }
  42.         else {
  43.         system("cls");
  44.     printf("\nNo. of Words = %d\nNo. of Vowels = %d\nNo. of Consonant = %d\nNo. of Space(s) = %d", nw,nv,nc,ns);
  45.     printf("\nNo. of Charecters = %d (No Space Count)", nchar);
  46. }
  47.  
  48. getch();
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement