andruhovski

prog0110-demo

Sep 11th, 2014
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4. int isvowel(char ch);
  5. int main( )    {  
  6.     char str[81];
  7.     int len, i, nvowel=0, nupper=0, nlower=0;
  8.     printf("Enter your string >");
  9.     gets(str);
  10.     len=strlen(str);
  11.     for (i=0; i<len; i++){
  12.         if (isvowel(str[i]))
  13.            nvowel++;
  14.     }
  15.     str[0]=toupper(str[0]);
  16.     for (i=1; i<len; i++)
  17.         str[i]=tolower(str[i]);
  18.     printf("Number of vowels     = %d\n", nvowel);
  19.     printf("Capitalised string   = %s\n", str);
  20.     system("pause");
  21.     return 0;
  22.  }
  23.  
  24. int isvowel(char ch){
  25.     int vowel;
  26.     char lower=tolower(ch);
  27.     vowel=lower=='a'||lower=='i'||lower=='o'||lower=='u'||lower=='e';
  28.     return vowel;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment