C Online Compiler
Example: Manual String Lowercase Conversion in C
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Manual String Lowercase Conversion #include <stdio.h> #include <string.h> // For strlen int main() { char str[] = "HeLlO WoRlD 123!"; // Step 1: Initialize the string int i = 0; printf("Original string: %s\n", str); // Step 2: Iterate through the string until the null terminator is found while (str[i] != '\0') { // Step 3: Check if the character is an uppercase letter (ASCII A-Z) if (str[i] >= 'A' && str[i] <= 'Z') { // Step 4: Convert to lowercase by adding 32 to its ASCII value str[i] = str[i] + 32; } i++; // Move to the next character } printf("Lowercase string: %s\n", str); // Step 5: Print the modified string return 0; }
Output
Clear
ADVERTISEMENTS