Guest User

Untitled

a guest
Jan 23rd, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. //Include definitions for C Runtime Library functions used in this program
  2. #include <stdio.h> //The standard I/O functions
  3.  
  4. //-------------------------------------------------------------------------------
  5. //This is the main function, invoked by the C Runtime (CRT) to start the program
  6. //-------------------------------------------------------------------------------
  7. int main(void) {
  8. int c, totalCharacters, upperCase, lowerCase, vowels, consonants, digits, capacity;
  9. c = totalCharacters = upperCase = lowerCase = vowels = consonants = digits = 0;
  10. capacity = 500;
  11. char stringArray[capacity];
  12.  
  13. gets(stringArray);
  14.  
  15. for(i = 0; stringArray[i] != NULL; i++){
  16. if(stringArray[i]=='a' || stringArray[i]=='e' || stringArray[i]=='i' ||
  17. stringArray[i]=='o' || stringArray[i]=='u')
  18. {
  19. ++vowels;
  20. ++lowerCase;
  21. ++totalCharacters;
  22. }
  23. else if(stringArray[i]=='A' || stringArray[i]=='E' || stringArray[i]=='I' ||
  24. stringArray[i]=='O' || stringArray[i]=='U')
  25. {
  26. ++vowels;
  27. ++upperCase;
  28. ++totalCharacters;
  29. }
  30. else if((stringArray[i]>='a') || stringArray[i]<='z')
  31. {
  32. ++consonants;
  33. ++lowerCase;
  34. ++totalCharacters;
  35. }
  36. else if((stringArray[i]>='A') || stringArray[i]<='Z')
  37. {
  38. ++consonants;
  39. ++upperCase;
  40. ++totalCharacters;
  41. }
  42. else if((stringArray[i]>='0') || stringArray[i]<='9')
  43. {
  44. ++digits;
  45. ++totalCharacters;
  46. }
  47. else
  48. {
  49. ++totalCharacters;
  50. }
  51. }
  52.  
  53. printf("upper-case: %d\n", upperCase);
  54. printf("lowerCase-case: %d\n", lowerCase);
  55. printf("vowels: %d\n", vowels);
  56. printf("consonants: %d\n", consonants);
  57. printf("digits: %d\n", digits);
  58. printf("total: %d\n", totalCharacters);
  59. }
Add Comment
Please, Sign In to add comment