Function to convert Lower Case Letters to Upper Case
Problem:
Write a function which receives a character (‘a’ to ‘z’ or ‘A’ to ‘Z’) and converts the receive character into uppercase. If you receive anything other than English alphabet then simply return it. The function prototype is as follows:
char toUpper( char )
Solution:
# include <iostream>
using namespace std;
char toUpper(char);a
int main()
{
char c;
cout<<"Please enter a Character : ";
cin>>c;
cout<<toUpper(c)<<endl;
return 0;
}
char toUpper(char c)
{
if(c>='a' && c<='z')
{
return c-32;
}
else
{
return c;
}
}
Write a function which receives a character (‘a’ to ‘z’ or ‘A’ to ‘Z’) and converts the receive character into uppercase. If you receive anything other than English alphabet then simply return it. The function prototype is as follows:
char toUpper( char )
Solution:
# include <iostream>
using namespace std;
char toUpper(char);a
int main()
{
char c;
cout<<"Please enter a Character : ";
cin>>c;
cout<<toUpper(c)<<endl;
return 0;
}
char toUpper(char c)
{
if(c>='a' && c<='z')
{
return c-32;
}
else
{
return c;
}
}