SHARE
TWEET

Untitled

a guest Aug 22nd, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void input(char inputArray[])
  5. {
  6.    
  7.     printf("What is your name? - ");
  8.     fgets(inputArray, 20, stdin);
  9.     inputArray[strlen(inputArray)-1] = '\0';
  10.        
  11.    
  12.     return;
  13. }
  14.  
  15. void printArray(char inputArray[])
  16. {
  17.     int i;
  18.    
  19.     printf("Your name is: ");
  20.    
  21.     for(i = 0; i < 20; i++)
  22.     {
  23.         printf("%c", inputArray[i]);
  24.     }
  25.    
  26.     printf("\n");
  27. }
  28.  
  29. void charcheckArray(char name[])
  30. {
  31.     int i;
  32.     int count = 0;
  33.     name = strlwr(name);
  34.    
  35.     for(i = 0; i < strlen(name); i++)
  36.  
  37.     {
  38.         if(name[i] >= 'a' && name[i] <= 'z')
  39.         count++;
  40.     }
  41.    
  42.     printf(" The number of characters in your name are: %d \n", count);
  43.    
  44.     return;
  45. }
  46.  
  47.  
  48. void charcountArray (char name [])
  49. {
  50.    
  51.     int i = 0;
  52.     int counter[26] = {0}, d;
  53.      
  54.      
  55.     name = strlwr(name);  
  56.    
  57.     while (name[i] != '\0')
  58.     {
  59.      
  60.       if (name[i] >= 'a' && name[i] <= 'z')
  61.       {
  62.          d = name[i] - 'a';
  63.          counter[d]++;
  64.          
  65.       }
  66.  
  67.       i++;
  68.     }
  69.    
  70.     for (i = 0; i < 26; i++)
  71.     {
  72.        
  73.         printf("There are %d %c's in your name! \n", counter[i], i + 'a');
  74.        
  75.     }
  76.    
  77.     printf("\n");
  78.     printf("\n");
  79.        
  80.     return;
  81. }
  82.  
  83. void numberCounter(char name [])
  84. {
  85.     int i;
  86.     int count = 0;
  87.     for(i = 0; i < strlen(name); i++)
  88.  
  89.     {
  90.         if(name[i] >= '0' && name[i] <= '9')
  91.         count++;
  92.     }
  93.    
  94.     printf(" The number of numbers in your name are: %d \n", count);
  95.    
  96.     return;
  97. }
  98.  
  99. void specialCheck(char name [])
  100. {
  101.     int i;
  102.     int count = 0;
  103.     for(i = 0; i < strlen(name); i++)
  104.  
  105.     {
  106.         if(name[i] >= ' ' && name[i] <= '/') // name[i] >= '{' && name[i] <= '~' )
  107.         count++;
  108.         else
  109.             if (name[i] >= ':' && name[i] <= '@')
  110.             count++;
  111.             else
  112.                 if (name[i] >= '[' && name[i] <= '`')
  113.                 count++;
  114.                 else
  115.                     if (name[i] >= '{' && name[i] <= '~' )
  116.                     count++;
  117.                    
  118.     }
  119.    
  120.     printf(" The number of special symbols in your name are: %d \n", count);
  121.    
  122.     return;
  123.    
  124. }
  125.  
  126.  
  127.  
  128. int main()
  129. {
  130.     char inputArray[20] = {'\0'};
  131.    
  132.    
  133.    
  134.     input(inputArray);
  135.     printArray(inputArray);
  136.     charcheckArray(inputArray);
  137.     charcountArray(inputArray);
  138.     numberCounter(inputArray);
  139.     specialCheck(inputArray);
  140.    
  141.    
  142.  
  143.     return 0;
  144. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top