C Program to convert lowercase string to uppercase
C Program to convert lowercase characters in a string to uppercase characters using loop or strupr string function. How to convert lowercase characters in a string to uppercase characters using loop or strupr string function. Logic to convert lowercase characters in a string to uppercase characters in C language.
C Program to convert lowercase string to uppercase using loop
#include <stdio.h>
void main()
{
char str[50];
int i=0;
printf("Enter lowercase string: ");
gets(str);
for (i = 0; str[i] != '\0'; i++)
{
if(str[i]>='a' && str[i]<='z')
{
str[i] = str[i] - 32;
}
}
printf("Uppercase string: %s", str);
}
C Program to convert lowercase string to uppercase using strupr()
function
#include <stdio.h>
#include <string.h>
void main()
{
char str[50];
printf("Enter lowercase string: ");
gets(str);
strupr(str);
printf("Uppercase string: %s", str);
}
Output
Enter lowercase string: procoding
Uppercase string: PROCODING