Google Add

Search

Write a Program to Convert String from LowerCase to UpperCase Without Using an Library Function


ASCII value of A is 65 and a is 97. So there is difference of 32 in every capital and corresponding small letter. To convert lowercase character into uppercase we subtract 32.

Program to Convert String from LowerCase to UpperCase

// Program

#include <stdio.h>
#include <string.h>

main()
{
   char str[100];
   int i;
   
   printf("Enter String");
   scanf("%s",str);
   
   // Loop through each character and subtract 32 from it.
   for(i=0;i<=strlen(str);i++){
       if(str[i]>=97 && str[i]<=122){
           str[i]=str[i]-32;
       }
       
   }
   
   printf("%s",str);
}


No comments:

Post a Comment