C Program to Convert String to Uppercase Without strupr

This C program converts all lowercase letters in the given string to uppercase without using string handling function strupr().

C Source Code: String Uppercase Without strupr


#include<stdio.h>

int main()
{
 char str[40];
 int i;

 printf("Enter string:\n");
 gets(str);

 for(i=0;str[i]!='\0';i++)
 {
  if(str[i]>='a'&& str[i]<='z')
  {
   str[i] = str[i]-32;
  }
 }

 printf("String in uppercase is:\n");
 puts(str);

 return 0;
}

Output

Enter string:
WeLcOmE To C 101. ↲
String in lowercase is:
WELCOME TO C 101.

Note: ↲ represents ENTER key is pressed.