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

Define the object-oriented terms, Question : (a) Define the following O...

Question : (a) Define the following Object-Oriented terms: (i) Encapsulation (ii) Inheritance (iii) Abstraction (iv) Polymorphism. (b) What are objects in Lingo progra

Explain the following object oriented methodologies, Question 1 Explain th...

Question 1 Explain the following Object Oriented Concepts with suitable examples for each Question 2 Explain the following Object Oriented Methodologies Question 3 Descr

Program is to find the maximum from two numbers, Program is to find the max...

Program is to find the maximum from two numbers: Program is to find the maximum from two numbers entered by the user having pointer variable as parameter void main()   {

Write a program to illustrate array of structures, Write a program to illus...

Write a program to illustrate array of structures? struct customer { int id; char name[15]; }; struct customer c[100]; . In the above instance, the array of Structures is

Why are all header files not declared in every c program, Why are all heade...

Why are all header files not declared in every C program? - Declaring all header files in each program would result in increase in overall file size and load of the program. It

Explain reference types, Reference Types The symbol "&" is interpreted ...

Reference Types The symbol "&" is interpreted as an address operator as well as AND operator. This operator is also used to declare a "reference variable". A reference is refer

#c++ homework, write c++programm that converts degrees Kelvin (TK) to degr...

write c++programm that converts degrees Kelvin (TK) to degrees Fahrenheit(TR) recall that TF=(9/5)TK and that TF=TR-459.67

Program is to reverse the names stored in an array pointer, Program is to r...

Program is to reverse the names stored in an array pointer: Program is to reverse the 6 names stored in an array pointer as name[] void main()   {  clrscr();  char

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