#include<iostream>
#include<string>
using namespace std;
int main()
{
string str="Hello World";
int i;
cout<<"The String is:
"<<str;
cout<<endl<<endl;
cout<<"String after uppercase lowercase modification:
";
for(i=0; i < str.length(); i++)
{
//if its uppercase add to its Ascii code 32 to make lowercase
if(str[i]>='A' && str[i]<='Z')
cout<<char(str[i]+32);
// else if its lowercase subtract 32 to make it upper case
else if(str[i]>='a' && str[i]<='z')
cout<<char(str[i]-32);
// else if its a space or symbol for example just print it as is
else cout<<str[i];
//the reason this works is that the distance in Ascii from uppercase to lowercase
//is standard and constant
}
return 0;
}