kucheasysa

lowercase array

Jun 6th, 2023
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void convertToLowercase(char arr[]) {
  4. int i = 0;
  5. while (arr[i] != '\0') {
  6. if (arr[i] >= 'A' && arr[i] <= 'Z') {
  7. arr[i] = arr[i] + 32; // Adding 32 converts uppercase to lowercase
  8. }
  9. i++;
  10. }
  11. }
  12.  
  13. int main() {
  14. char input[100];
  15.  
  16. printf("Enter a character array: ");
  17. fgets(input, sizeof(input), stdin);
  18.  
  19. convertToLowercase(input);
  20.  
  21. printf("Converted array: %s\n", input);
  22.  
  23. return 0;
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment