[et_pb_section fb_built=”1″ _builder_version=”4.4.0″][et_pb_row _builder_version=”4.4.0″][et_pb_column type=”4_4″ _builder_version=”4.4.0″][et_pb_text _builder_version=”4.4.2″ text_font=”Verdana||||||||” text_text_color=”#000000″ text_font_size=”16px” text_letter_spacing=”1px” custom_padding=”||0px|||” hover_enabled=”0″]

Converting string lowercase to uppercase

Converting string lowercase to uppercase in this tutorial – we will discuss how to convert lowercase to the uppercase string using the built-in method and without using the Built-in method in C programming language-C language to provide us the inbuilt method toupper() to change lowercase to an uppercase string.

 

[/et_pb_text][et_pb_text _builder_version=”4.4.1″ header_4_font=”|600|||on||||” header_4_text_color=”#000000″ min_height=”0px” custom_margin=”-23px|||||”]

Using toupper()

[/et_pb_text][et_pb_text _builder_version=”4.4.1″ text_font=”|600|||||||” text_text_color=”#000000″ text_font_size=”15px” border_radii=”on|8px|8px|8px|8px” border_width_all=”3px” border_style_all=”double”]

int main()
{
   char st[]="manas halder";
   char ch; 
   for(int i=0; st[i]!='\0'; i++)
    {
      ch=st[i];
      printf("%s"(toupper(ch));
    }
   return 0;
}

[/et_pb_text][et_pb_image src=”https://digitalmind.online/wp-content/uploads/2020/03/lo_up.png” _builder_version=”4.4.1″][/et_pb_image][et_pb_text _builder_version=”4.4.2″ text_font=”Verdana||||||||” text_text_color=”#000000″ text_font_size=”17px” custom_padding=”||0px|||” hover_enabled=”0″]

Now we will see that without using a built-in method of how to convert lowercase to uppercase string.

Before we go ahead we need to know about the ASCII code. An ASCII code is the method of representing characters as an integer, which is a 7-bit representation.

For lowercase letters that are for a,b,c,d…..x,y,z, the ASCII values lie in the range of 97,98,99,…….122.

For uppercase letters that is A, B, C, D …… X, Y, Z, and the ASCII values lie in the range of 65,66,67……89,90.

Logic is that we check the ASCII code of the lowercase character if the ASCII code lies between 97 to 122 then subtract 32 so that it will automatically be converted from lowercase to uppercase character.

 

[/et_pb_text][et_pb_text _builder_version=”4.4.0″ header_4_font=”|600|||||||” header_4_text_align=”center” header_4_text_color=”#000000″]

Source Code

[/et_pb_text][et_pb_text _builder_version=”4.4.1″ text_font=”Verdana|600|||||||” text_text_color=”#000000″ text_font_size=”15px” border_radii=”on|8px|8px|8px|8px” border_width_all=”3px” border_style_all=”double”]

int main()
{
char str[25];
int i;
printf("\nEnter the string to change lower to uppercase");
gets(str);
for(i=0; str[i]!='\0'; i++)
{
if(str[i]>='a'&& str[i]<='z')
str[i]=str[i]-32;
} printf("\nNew uppercase string is=%s", str);
}

 

[/et_pb_text][et_pb_text _builder_version=”4.4.0″ header_4_font=”|600|||||||” header_4_text_align=”center” header_4_text_color=”#000000″]

Output

[/et_pb_text][et_pb_image _builder_version=”4.4.1″][/et_pb_image][et_pb_text _builder_version=”4.4.2″ text_font=”Verdana||||||||” text_text_color=”#000000″ text_font_size=”16px” text_letter_spacing=”1px”]

Converting String lowercase to uppercase – as we mentioned before all the lowercase characters [a to z] ASCII value ranging from 97 to 122 and uppercase character [A to Z] ASCII value ranging from 97 to 122. So the following program we are going to use direct  ASCII value instead of using a character.

[/et_pb_text][et_pb_text _builder_version=”4.4.1″ text_font=”Verdana|600|||||||” text_text_color=”#000000″ text_font_size=”15px” border_radii=”on|8px|8px|8px|8px” border_width_all=”3px” border_style_all=”double”]

int main()
{
   char st[25];
   int i,len;
   printf("\n\n\tEnter the string lower to uppercase");
    gets(st);
   len=strlen(st);
   for(i=0; i<len; i++)
    {
      if(st[i]>=97 && st[i]<=122)
           st[i]=st[i]-32;
     }
    printf("\n\n\tNew uppercase string is=%s",st);
}

[/et_pb_text][et_pb_text _builder_version=”4.4.0″ header_4_font=”Verdana|600|||||||” header_4_text_align=”center” header_4_text_color=”#000000″]

output

[/et_pb_text][et_pb_image src=”https://digitalmind.online/wp-content/uploads/2020/03/lo_up.png” _builder_version=”4.4.1″][/et_pb_image][et_pb_text _builder_version=”4.4.1″ header_3_font=”Verdana|600|||||||” header_3_text_color=”#000000″]

Recommended Post is following

How to write a C program to the uppercase character to the  lowercase string using builtin and without builtin method.

How to Write a C program to find out the Second smallest number of Array elements.

How to Write a C program to find out the Second highest number of Array elements.

How to write Right Triangle using star “*” symbol in C program

How to make “X” type pattern using the symbol in C programming

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]