Sunday, 20 March 2016

C Program to Convert String Lowercase to Uppercase And Vice Versa

Problem:- 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.

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

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.


Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.


Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page.


Solution:-

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

void main()
{
/*Visit - www.programmingwithbasics.com*/
   
    printf("=====================================");
    printf("\nVisit - www.programmingwithbasics.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:-

C Program to Convert String Lowercase to Uppercase And Vice Versa

You May Also See


1. C Program For Reverse A given Number Using While Loop

2. C Program To Find Number Is Armstrong Or Not using While Loop

3. C Program to Calculate Sum of Natural Numbers Using While Loop

4. C Program To Print Multiplication Table Using For Loop

5. C Program to Display Fibonacci Series Using While Loop


Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment