C Programming Code Examples C > Strings Code Examples C program to convert lowercase string to uppercase C program to convert lowercase string to uppercase Write a C program to convert string from lowercase to uppercase string using loop. How to convert string from lowercase to uppercase using for loop in C programming. C program to convert lowercase to uppercase string using strupr() string function. Logic to convert lowercase string to uppercase Internally in C every characters are represented as an integer value known as ASCII value. Where A is represented with 65 similarly, B with 66. Input string from user, store it in some variable say str. Run a loop from 0 till end of string. Inside loop check if current string is lowercase then convert it to uppercase str[j] = str[j] - 32. Now, why subtracting it with 32. Because difference of a - A = 32. Algorithm to convert lowercase to uppercase %%Input : text {Array of characters / String} N {Size of the String} Begin: For j = 0 to N do If (text[j] >= 'a' and text[j] <= 'z') then text[j] = text[j] - 32; End if End for End #include <stdio.h> #define maxsize 100 // Maximum string size int main() { char str[maxsize]; int j; /* Input string from user */ printf("Enter your text : "); gets(str); for(j=0; str[j]!='\0'; j++) { /* * If current character is lowercase alphabet then * convert it to uppercase. */ if(str[j]>='a' && str[j]<='z') { str[j] = str[j] - 32; } } printf("Uppercase string : %s",str); return 0; }