 Hello friends, I am Sanjay Bhukta. I welcome you on Sanjay Bhukta Tech School. In this video, I am going to explain how you can convert uppercase matter to lowercase and lowercase matter to uppercase. Those are available in our stream and I will be implementing this with the help of ASCII values. So I will also explain them what are ASCII values and how we can use them. Before start, I just want to share one information. If you go to detail or description of this video, you will find links of various playlists related to C language to get so you can follow them too. So now coming on to the topic for this video. So first of all, I am writing beginning statements of the program. So I am declaring one string then one in these are variable that divide. Now to read string from user, I am writing a print out statement. And then get us as here. Right. So these are very simple statements those are required for every program if you are performing any kind of operation. So now we need to understand how we can convert uppercase to lowercase and how we can convert lowercase to uppercase. So here I will be using ASCII values. Those are available in stream. So ASCII stands for American Standard Code for Information Interchange, American Standard Code for Information Interchange. So in case of programming, each character is having predefined ASCII values. So right now we need two type of ASCII values one for uppercase and one for lowercase. So I am writing those. So for capital A to Z we have 65 to 90. 65 is for capital A, 66 is capital B and so on. And for small a to Z we have 97 to 122. So 97 is for small a, 98 is for small b and so on. Right. Now in case if you have capital A, if you have capital A as string value and you want to convert it into small a, you want to convert it into small a. So you can just add 32. So this 32 will be added to ASCII value of this A. So capital A ASCII value is 65, 32 will be added and it will become 97. Right. So wherever we apply mathematical operation on character constraints, so they internally automatically converts into ASCII code that operation will happen. And 97 will become small a automatically while we will be storing that into character variable or string. So if you want to convert uppercase into lowercase, so you need to add plus 32. So if we add plus 32 for capital A, so it will become small a. If we add 32 in capital B, so it will be converted into small b because difference between all the ASCII uppercase and lowercase values are 32. And if you want to do vice versa, like you want to convert lowercase into uppercase, so you can simply subtract 32. So lowercase ASCII value is higher than uppercase. So you need to subtract 32. So if we subtract 32 from 97, it will again become 65 that is equal into capital. So this logic we are going to use to fulfill this requirement for strings. So now I'm going to implement a loop. It will repeat till null character. So inside this loop, I need to check that the string is containing uppercase or it is containing lowercase. So here I am putting this. So str of i is greater than equals to 65 and str of i is less than equals to 90. So if the character which is available in string exists between this range or that character's ASCII value is between these 65 to 90 range, then it will be uppercase. So we can convert it into lowercase like this. You need to simply add to that character 32 so that it will be converted into lowercase and that will be assigned back into that. Then else if str of i is greater than equals to 97 and str of i is less than equals to 122. So it means the character which is available in string is a lowercase because that characters ASCII lies between this range. So you can write str of i equals to str of i minus 32. So this way the conversion is happening. So if it is uppercase, we are adding 32 so it will be converted into lowercase. If it is lowercase, then we are subtracting 32 so it will be converted to uppercase. And after this conversion, you can print the result. So if you implement this program in your laptop, so you can see the output of str will be having all the uppercase are converted into lowercase and lowercase are converted into uppercase. And how this conversion takes place? So I already explained you by taking a simple example. So internally all the characters are converted to the corresponding ASCII values whenever we apply any mathematical operation on them. So remember this like if you are applying any operation on characters, they will be converted into ASCII value. So you can simply add or subtract any digit to those characters because internally that operation is happening with the help of ASCII values. And if we assign any ASCII value back to that character of string, so that will be converted automatically into corresponding character. So this takes place automatically. So you just need to remember the gap between uppercase and lowercase ASCII value that is 32. So from lower to upper add 32 from lower to upper subtract 32. So this you need to remember and you can just remember these ASCII values as well. And if you don't remember this ASCII value, so here you can put capital A in single quotes and here you can put capital Z in single quotes. And similarly in place of 97 you can place small A in single quotes and here you can put small Z in single quotes. So if you don't remember ASCII value then also you can implement this program if you know that you can directly use them as well. So I hope this way you understood how we can convert uppercase to lowercase and lowercase to uppercase in a string. And if you want to watch more programming related videos, you can open my channel, go to playlist and see various variety of programs. Also you can go to detail or description of this video where I have already mentioned links of all playlist related to C language. Those are available on my channel. So do watch them and thank you for watching them.