TOLOWER()

this is used to convert characters from uppercase to lowercase. this is useful for text manipulation, ensuring uniformity or performing case-insensitive comparisons. If the character is not an uppercase letter, it returns the character unchanged.

int tolower(int ch);
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main() {
    char str[] = "Hello, World!";  // Predefined string

    // Print the original string
    printf("Original string: %s\n", str);

    // Convert the string to uppercase
    for (int i = 0; i < strlen(str); i++) {
        str[i] = toupper(str[i]);  // Convert each character to uppercase
    }

    // Print the uppercase string
    printf("Uppercase string: %s\n", str);

    // Convert the string back to lowercase
    for (int i = 0; i < strlen(str); i++) {
        str[i] = tolower(str[i]);  // Convert each character to lowercase
    }

    // Print the lowercase string
    printf("Lowercase string: %s\n", str);

    return 0;
}

Last updated