Lowercase to Uppercase
Algorithm
Input Lower case character Output Uppercase character. Complexity O (n). Upper to lower case (char[]) 1. Set n=number of character in char[]; 2. For i=1 to n 3. Do if (95 <=char[i] <=122) 4. Then char[i]=(char[i]-32); 5. Print char[i];
Algorithm Description
1. Chat[] :character array;
2. For loop for each element in the array. If integer value corresponding a character lie between 95 to 122 this means it’s a lower case character, by subtracting 32 it can be converted to upper case.
C Code
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char str[100];
int i,n,d;
printf(" \n enter the string in lower case : ");
gets(str);
n=strlen(str);
for(i=0 ;i<n ;i++)
{
d=str[i];
if(d>=95 && d<=122)
{
printf("%c",d-32);
}
else
{
printf("%c",str[i]);
}
}
return(0);
}