SalvatorederRote

c a d

Aug 26th, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cs50.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5.  
  6.  
  7. int main(int argc, string argv[])
  8. {  
  9.    
  10.         string s = GetString();
  11.        
  12.         if (s != NULL && s != '\0')
  13.         {
  14.             for (int i = 0, n = strlen(s); i < n; i++) /// Loop through string.
  15.             {
  16.                 if (s[i] == s[0])
  17.                 {
  18.                     printf("%c", toupper (s[0])); /// Loop through index, when index first character print it.
  19.                 }
  20.                 if (s[i] == ' ') /// Loop through string, look for space, then print +1 chararacter after space.
  21.                 {
  22.                     printf("%c", toupper (s[i+1]));
  23.                 }
  24.             }  
  25.         }
  26.         printf("\n");
  27. }
Add Comment
Please, Sign In to add comment