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

Area under the curve, Write a program to find the area under the curve y = ...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Curve, Write a program to find the area under the curve y = f(x) between x ...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Function, #q•Design and code a new function that accepts as parameters the ...

#q•Design and code a new function that accepts as parameters the gross pay by value and the federal tax, state tax, local tax, SS tax, and net Pay by reference. Calculate the taxes

Introduction to c programming, How would you print the values of the variab...

How would you print the values of the variables words and lines so they appear in the form: There were 6040 words and 680 lines. Here, 6040 and 680 represent the values of the two

Write a program that calculates points along a curve, write a program that ...

write a program that calculates points along a rhodonea curve.... ? int fillArray( double data[ ], int nValues, double min, double max ); o Used to fill in the theta array. Return

What happens while a derived-class object is developed, What happens while ...

What happens while a derived-class object is developed & destroyed? A: Space is allocated (on the heap or the stack) for the full object (i.e. adequate space to store the data m

I want youtube down-upload boots, Project Description: Boots capture vid...

Project Description: Boots capture video from your YouTube channel and upload your own video to our channel or the copyright of the videos, bang, 3 parties, automatically delete

C program to convert number to binary, Write a program in C that you will n...

Write a program in C that you will name "divide.exe", to divide one 32-bit twos-complement binary number by another, giving the quotient and the remainder, using the subtract-shift

Object oriented programming and cryptography, This assignment document will...

This assignment document will be distributed from Blackboard assignment folder. Some parts of the assignments will require you to research answers from your text book (you must rea

What is a hash function, What is a hash function? Hash function: This ...

What is a hash function? Hash function: This is the method from the set 'K' of keys into the set 'L' of memory addresses.   H: K → L These are used to verify the address

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