You are on page 1of 2

#include<iostream>

using namespace std;


int main()
{
    char a[]="vishnu";
    for(int i=0;a[i]!='\0';i++)
    {
        a[i]=a[i]-32;
    }
    cout<<"new string is "<<endl;
    for(int i=0;a[i]!='\0';i++)
    {
        cout<<a[i];
    }
    cout<<endl;
}
//change the case of the character
#include<iostream>
using namespace std;
int main()
{
    char a[]="vIsHnU";
    cout<<"before"<<endl;
    for(int i=0;a[i]!='\0';i++)
    {
        cout<<a[i];
    }
    cout<<endl;
    for(int i=0;a[i]!='\0';i++)
    {
        if(a[i]>=65 && a[i]<=90)
        {
            a[i]=a[i]+32;
        }
        else if(a[i]>=97 && a[i]<=122)
        {
            a[i]=a[i]-32;
        }
    }
    cout<<"after "<<endl;
    for(int i=0;a[i]!='\0';i++)
    {
        cout<<a[i];
    }
    cout<<endl;
}
//convert the string in desierd case
#include<iostream>
using namespace std;
int main()
{
    string name;
    cout<<"enter your name in any case "<<endl;
    cin>>name;
    int choice;
    cout<<"enter the choice  1.for to convert the given string in uppercase
and "<<endl;
    cout<<"enter 2.to convert the given string in lowercase "<<endl;
    cin>>choice;
    switch (choice)
    {
    case 1:for(int i=0;name[i]!='\0';i++)
    {
        if(name[i]>=97 && name[i]<=122)
        {
            name[i]=name[i]-32;
        }
    }
    cout<<"all the characters are present in upper cases "<<endl;
    for(int i=0;name[i]!='\0';i++)
    {
        cout<<name[i];
    }
    cout<<endl;
    break;
    case 2:for(int i=0;name[i]!='\0';i++)
    {
        if(name[i]>=65 && name[i]<=90)
        {
            name[i]=name[i]+32;
        }
    }
    cout<<"all the character are in lower cases "<<endl;
    for(int i=0;name[i]!='\0';i++)
    {
       cout<<name[i];
    }
    cout<<endl;
        break;
   
    default:
        break;
    }

You might also like