"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Friday, January 8, 2010

A menu driven program to enter a text(word / sentance) and convert it into Uppercase , Lowercase, Togglecase as per the user choice.


#include<iostream.h>
#include<conio.h>
#include<string.h>
{
char str[30], choice;
cout<<"\n Enter A String :";
cin.getline(str,30);
int t,i;


do{
cout<<"*************** MENU ********************\n";
cout<<"\n\n 1. UPPERCASE.";
cout<<"\n 2. LOWERCASE.";
cout<<"\n 3. TOGGLECASE.";


cout<<" Enter your choice (1-2-3)";
cin>>t;


switch(t)
{
case 1:
           for( i = 0; str[i] != '\0' ; i++)
                  str[i] = toupper(str[i]);
           cout<< "\n The output =" << str;


           break;
case 2:


          for( i = 0; str[i] != '\0' ; i++)
              str[i] = tolower(str[i]);
          cout<< "\n The output =" << str;


          break;
case 3:
          for( i = 0; str[i] != '\0' ; i++)


         {            
          
            if(isupper(str[i])
               str[i] = tolower(str[i]);
            if(islower(str[i])


               str[i] = toupper(str[i]);
            }
           cout<< "\n The output =" << str;
            break;
default:
             cout<<"\n Invalid choice.";
}


cout<<"\n Do you continue ?(Y/N)";
cin>>choice;
}while(toupper(choice)= ='Y');
}

No comments:

Post a Comment

C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.