Covert a string to upper case

void ToUpper(char * S)
{
while (*S!=0)
{
*S=(*S >= ‘a’ && *S <= ‘z’)?(*S-‘a’+‘A’):*S;
S++;
}
}

//dancing doll…..means lower->upper n vice-versa…its simple to implement

//A-Z(65-90) n a-z(97-122) ASCII value..

#include<iostream>
using namespace std;

main()
{
char b;
cout<<“\n enter any char :”;
while(cin>>b)
{
if(int(b)>96)
cout<<” its inverted is :”<<(char)((int)b-32)<<“\n\n enter any char: “;
else if(int(b)<97)
cout<<” its inverted is :”<<(char)((int)b+32)<<“\n\n enter any char: “;
}

cout<<endl<<endl;
system(“pause”);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: