uppercase input to lowercase output


/ Published in: C
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /* output in lowercase */
  2.  
  3. #include <stdio.h>
  4.  
  5. int lower(int upper);
  6.  
  7. int main(int argc, const char *argv[]){
  8. int c;
  9. c=getchar();
  10. while(c != EOF){
  11. if(c<65 || c>90){
  12. putchar(c);
  13. c=getchar();
  14. }
  15. else{
  16. putchar(lower(c));
  17. c=getchar();
  18. }
  19. }
  20. }
  21.  
  22. int lower(int upper){
  23. upper=upper+32;
  24. return(upper);
  25. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.