SabirSazzad

String Lab task(count vouel,consonent,digit)

Feb 20th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.54 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. int main ()
  4. {
  5.      char paragraph[] = "AMERICAN INTERNATIONAL UNIVERSITY-BANGLADESH (AIUB) envisions promoting professionals and excellent leadership catering to the technological progress and development needs of the country.";
  6.  
  7.      int i,j,vow=0,cons=0,digi=0,spc=0;
  8.  
  9.      char *vowel = "AEIOUaeiou";
  10.      char *consonant = "BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz";
  11.      char space = ' ';
  12.      int digit[10]= {0,1,2,3,4,5,6,7,8,9};
  13.  
  14.      for (i=0; vowel[i] != '\0' ;i++)
  15.      {
  16.  
  17.          for(j=0; paragraph[j] != '\0' ; j++)
  18.          {
  19.              if (vowel [i] == paragraph [j])
  20.              {
  21.                  vow++;
  22.              }
  23.          }
  24.  
  25.      }
  26.      printf("Number of Vowel is: %d\n",vow);
  27.  
  28.  
  29.      for (i=0; consonant[i] != '\0' ;i++)
  30.      {
  31.  
  32.          for(j=0; paragraph[j] != '\0' ; j++)
  33.          {
  34.              if (consonant [i] == paragraph [j])
  35.              {
  36.                  cons = cons + 1;
  37.              }
  38.          }
  39.  
  40.      }
  41.      printf("Number of Consonant is: %d\n",cons);
  42.  
  43.  
  44.      for (i=0; i<10 ;i++)
  45.      {
  46.  
  47.          for(j=0; paragraph[j] != '\0' ; j++)
  48.          {
  49.              if (digit [i] == paragraph [j])
  50.              {
  51.                  digi = digi + 1;
  52.              }
  53.          }
  54.  
  55.      }
  56.      printf("Number of Digit is: %d\n",digi);
  57.  
  58.  
  59.      for(i=0; paragraph[i] != '\0' ; i++)
  60.      {
  61.          if (paragraph[i] == space)
  62.          {
  63.              spc = spc + 1;
  64.          }
  65.      }
  66.      printf("Number of White Space is: %d\n",spc);
  67.  
  68.  
  69.      return 0;
  70.  
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment