Advertisement
Lisaveta777

Prata exs 9.7

Aug 31st, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3.  
  4. int func1(char);
  5. int main()
  6. {
  7.     char ch;
  8.     int result;
  9.  
  10.     while((ch = getchar())!= EOF)
  11.     {
  12.         result =func1(ch);
  13.         printf("result is %d\n",result);
  14.  
  15.     }
  16.  
  17.     return 0;
  18. }
  19.  
  20. int func1(char c)
  21. {
  22.     int res;
  23.     if(islower(c))
  24.     {
  25.         res = c - 'a'+1;
  26.     }
  27.     else if(isupper(c))
  28.     {
  29.         res = c - 'A'+1;
  30.     }
  31.     else
  32.         res = -1;
  33.     return res;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement