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

Explain bit-wise operators, Bit-wise Operators Some applications requir...

Bit-wise Operators Some applications require operations to be done on dissimilar bits of a byte separately. Bit-wise operators offer a facility to do just that. There are vario

Project, Project Overview A certain financial institution (bank) wishes to ...

Project Overview A certain financial institution (bank) wishes to promote its new business products/services by conducting road shows in rural areas. Their aim is to encourage peop

Define a structure in c++, Define a structure in C++: Write a program ...

Define a structure in C++: Write a program a structure in c++ program. void main() {                 struct player                 {                 char name[2

Define scope rules of c program - computer programming, Define Scope Rules ...

Define Scope Rules of C program - Computer Programming? The fundamental rule of scope is that identifiers are accessible only within the block in which they are declared and th

Write a program to test the class, Problem Implement a class called emp...

Problem Implement a class called employee that contains name, employee number and department code. Include a member function getdata() to get data from user and store it in the

Experiment with the small test matrix, For this assignment, I've provided a...

For this assignment, I've provided a data file called 'elevation.mat', which contains the elevation data you'll be working with.   Type load elevation.mat to get the varia

Expected output of the program - c program, Expected output of the program:...

Expected output of the program: 1. Consider the following programs. For each, indicate whether the program is correct. If yes, what is the expected output? If not, what is the

What is mime, What is MIME? MIME - Multi-purpose Internet Mail Extens...

What is MIME? MIME - Multi-purpose Internet Mail Extensions. MIME types signifies a standard way of classifying file types over Internet. Browsers and Web servers have

Output, #include void func(int num, b=5) { auto int total=0; static ...

#include void func(int num, b=5) { auto int total=0; static int sum=0; for ( int i=num; i>0 ; i--) total+=i; sum+=total; cout

Fibonacci series, draw the flow chart to print the fibonacci series upto n ...

draw the flow chart to print the fibonacci series upto n th terms

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