Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
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'); }
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'); }
/* void string::capital()
}*/
void string::copying()
char tempstr[100];
int i=0;
while(str[i]!=NULL)
tempstr[i]=str[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'); }
void string::vowel()
while (str[i]!=NULL)
if(str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' ||str[i]=='u')
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'); }
/* else
if(str[i]=='A' || str[i]=='E' || str[i]=='I' || str[i]=='O' || str[i]=='U')
counti++;
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'); }
void main()
int n;
string option;
do
mainmenu();
cin>>n;
switch(n)
case 1:option.read();
break;
case 2:option.display();
case 3:option.reverse();
// case 4:option.capital();
//break;
case 5:option.copying();
case 6:option.vowel();
case 7:exit(0);
default: cout<<" wrong choice ";
}while(n!='7');
program code
explain the function of five elements that are found on a motherboard#
i have a project that is due this Wednesday and i was wondering if i can get help in doing it?
how yo use the friend function?
Problem Write a program in C++ to read N numbers in an array, the user should be able to search a particular number in the array using sequential search algorithm. Writing a
ABC Car Dealership needs your help to update the ordering system. This car dealer is selling four types of vehicles: Sedan, Truck, SUV, and mini Van. And each type of vehicle can h
how to implement a state transition diagram?
How do you write the code for summations
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
Write a program consisting of two functions (plus main). The first function should read in a number and then pass this back to main. This value should then be passed into a secon
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!
whatsapp: +1-415-670-9521
Phone: +1-415-670-9521
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd