Q:

C Program to Convert String Lowercase to Uppercase And Vice Versa

belongs to collection: String in C Programs

0
 Program to change lowercase to uppercase and vice-versa or C Program to Replace Lowercase Characters by Uppercase & Vice versa or Convert Upper to Lower Case Alphabets & Vice-versa or How to convert a given string into lowercase and uppercase without using library functions in C or C program to change case of a string or Case conversion (Lower to Upper and Vice Versa) of a string or conversion from uppercase to lowercase using c program or Convert all lowercase characters to uppercase and vice-versa.
 
 
Explanation:-
 As we know that for an every character in keyboard has unique ASCII Value for Capital Alphabet(Upper Case) and Small Alphabet(Lower Case) so for converting a any case to any case (lower case to upper case and upper case to lower case) we have to remember number 32 cause this is a number for converting an any string into any case we have to just add the number 32 or minus the number 32 from each character of the string and we solved our conversion problem. I strongly recommend checking the ASCII program in C. So in this problem, we are just comparing if the number is less then the lower case ASCII number change convert it into the upper case or vice versa.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

void main()
{
   
    printf("=====================================");
    printf("\nnerdutella.com");
    printf("\n=====================================");
    
    while(1)
    {
 char str[20];
    int i;

    printf("\n\nEnter The String: ");
    scanf("%s",str);

    for (i=0;i<=strlen(str);i++)
  {
        if (str[i]>=65&&str[i]<=90)
        {
         str[i] = str[i] + 32;
  }    

        else if (str[i] >= 97 && str[i] <= 122)
        {
         str[i] = str[i] - 32;
  }    
    }
    
    printf("\n\nConvert String(Lower/Upper) Is: %s\n\n",str);
 }

    return 0;
}

 

Output:

=================================

nerdutella.com

=================================

Enter The String :examples

Convert String (Lower/Upper) IS:EXAMPLES

Enter The String: PROGRAMMING

Convert String (Lower/Upper) Is: programming

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Program For Reverse A String Using Library Funct... >>
<< C Program to Convert String to Integer Without Usi...