C Program to Convert the string from lowercase to UPPERCASE:There we sill discuss about the lowercase String and UPPERCASE string.
ASCII value of 'A' is 65 and 'a' is 97. Difference between them is 97 – 65 = 32 So if we will add 32 in the ASCII value of 'A' then it will be 'a' and if will we subtract 32 in ASCII value of 'a' it will be 'A'.
It is true for all alphabets. In general rule:
Upper case character = Lower case character – 32
Lower case character = Upper case character + 32.
ALGORITHM:-
step 1 : Start
step 2 : First take an character array
step 3 : Enter the string value in array
step 4 : Calculate the lenght of the string
step 5 : if(string[i] >=97 and <=122) then subtract the 32
step 6 : Print the string value
step 7 : Stop
PROGRAM CODE:-
#include<stdio.h>
#include<conio.h>
void main()
{
char str[20];
int i;
printf("Enter any string->");
scanf("%s",str);
printf("The string is->%s",str);
for(i=0;i<=strlen(str);i++)
{
if(str[i]>=97&&str[i]<=122)
{
str[i]=str[i]-32;
}
}
printf("\nThe string in Uppercase is->%s",str);
getch();
}
OUTPUT:-
Enter Any String->
cprogrammingsimply
The string in Uppercase is->
CPROGRAMMINGSIMPLY
C Program to convert any string from lowercase to UPPERCASE String Convertion from lowercase to uppercase String lowercase and uppercase using C
ConversionConversion EmoticonEmoticon