khalfella

ansi_c_pg49_ch02_ex10.c

Nov 2nd, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. /*
  2. * Exercise 2-10.
  3. * Rewrite the function lower, which converts upper case letters to lower case,
  4. * with a conditional expression instead of if-else.
  5. */
  6.  
  7. #include <stdio.h>
  8.  
  9.  
  10. int lower(int c)
  11. {
  12. return ((c >= 'A' && c <= 'Z')?(c+'a'-'A'):c);
  13. }
  14.  
  15.  
  16. int
  17. main() {
  18. printf ("%c\n",lower('K'));
  19. }
Advertisement
Add Comment
Please, Sign In to add comment