Program is to perform string operations, C/C++ Programming

Assignment Help:

Program is to perform string operations:

Program is to perform string operation without using in built functions using classes and object

void mainmenu()

   {

   clrscr();

   cout<<"\n\t   Enter your choice\n ";

   cout<<"\n\t1. to read the string ";

   cout<<"\n\t2. to display the string ";

   cout<<"\n\t3. to reverse the string ";

   cout<<"\n\t4. to capitalize the string ";

   cout<<"\n\t5. to copy the string into an empty string";

   cout<<"\n\t6. to count the no. of vowels [upper and lower case] ";

   cout<<"\n\t7. Quit ";

   cout<<"\n\n\t Enter choice ";

   }

 

 class string

   {

   private:

                  char str[100];

   public:

                  void read();

                  void display();

                  void capital();

                  void copying();

                  void reverse();

                  void vowel();

                  void quit()

                {

                exit(0);

                }

   };

 

  void string::read()

                {

                cout<<" enter a string ";

                gets(str);

                }

 

  void string::display()

                {

                cout<<" the string you have entered  is "<

                getch();

                }

 

  void string::reverse()

                {

                 int count=0;

                 char temp;

                 for (int i=0;str[i]!= NULL;i++)

                  count++;

                  for(i=0;i<=count/2;i++)

                   {

                   temp=str[i];// reverse 1st string

                   str[i]=str[count-1-i];

                   str[count-1-i]=temp;

                   i++;

                   }

                   cout<<" reversed "<

                   getch();

                 }

  /*  void string::capital()

                 {

                  }*/

  void string::copying()

   {

                char tempstr[100];

                int i=0;

                while(str[i]!=NULL)

                 {

                 tempstr[i]=str[i];

                 i++;

                 }

                 cout<<" the string copied into a new empty string "<

                 getch();

   }

 

 void string::vowel()

  {

   int count=0;

   int i=0;

   while (str[i]!=NULL)

                {

   if(str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' ||str[i]=='u')

                 {

                count++;

                i++;

                 }

                cout<<" the vowels in lower case "<

/*   else

   if(str[i]=='A' || str[i]=='E' || str[i]=='I' || str[i]=='O' || str[i]=='U')

                  {

                  counti++;

                  i++;

                  }

                 cout<<" the vowels in upper case "<

                }

  }

 

 void main()

  {

  int n;

  string option;

   do

                {

                 mainmenu();

                  cin>>n;

                   switch(n)

                                {

                                case 1:option.read();

                                                   break;

                                case 2:option.display();

                                                   break;

                                case 3:option.reverse();

                                                   break;

                //            case 4:option.capital();

                                                   //break;

                                case 5:option.copying();

                                                   break;

                                case 6:option.vowel();

                                                   break;

                                case 7:exit(0);

                                                   break;

 

                                default: cout<<" wrong choice ";

                                }

                }while(n!='7');

  }


Related Discussions:- Program is to perform string operations

Write a program to calculate the timetable, Write a program to calculate th...

Write a program to calculate the timetable for numbers 1 -> 10 and display them as follows. Your solution should use for do loops      #include stdio.h void main() {    char p

Online poker web application, Project Description:  LOOKING TO DEVELOP ...

Project Description:  LOOKING TO DEVELOP A ONLINE POKER Web Application. WEBSITE WILL BE DEVELOPED OVER THE NEXT 6 MONTHS Duration & WILL REQUIRE FULL SOFTWARE CODING OF WEB

C++, Write C++ code for calculating the time table

Write C++ code for calculating the time table

Example for external storage class - computer programming, Example for exte...

Example for external storage class - computer programming? extern double sin (double); In a function prototype, for the sin() function its function definition ~ we can write

When should you use multiple inheritance, There are 3 acceptable answers: "...

There are 3 acceptable answers: "Never," "Rarely "and" When the problem domain cannot be accurately modelled any other way."

How does a structure differ from an array, Question : (a) What is a str...

Question : (a) What is a structure? Provide a simple example of your own to illustrate this feature. (b) How does a structure differ from an array? (c) Describe a structu

Decode the code, Smugglers are becoming very smart day by day. Now they hav...

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Computer Science Engineering C++ Homework, Temperature Conversions. Problem...

Temperature Conversions. Problems 28 through30generate temperature-conversion tables. Use the following equations that give relationships between temperatures in degrees Fahrenheit

Describe processing an array, Describe Processing an array? The Single ...

Describe Processing an array? The Single operations which involve complete arrays are not permitted in C language. therefore if a and b are similar arrays (for example same dim

Find out the largest torque, Find out the largest torque: A flat belt...

Find out the largest torque: A flat belt is taken in use to transmit torque from pulley A to pulley B as shown in figure given below. The radius of each pulley is 50mm and co

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd