Monday, 30 September 2024

Journal Program 7

 #include<iostream.h>

#include<conio.h>

#include<string.h>

#include<process.h>

#include<ctype.h>

class String

{

char str[100];

public:

void getData()

{

cout<<"Enter string : ";

cin>>str;

}

void strlen1()

{

int len;

len=strlen(str);

cout<<"\nLength of "<<str<< " is "<<len;

}

void strrev1()

{

cout<<"\nReverse of "<<str<<" is :"<<strrev(str);

}

void strupr1()

{

cout<<"\nUpper Case of string is ="<<strupr(str);

}

void strlwr1()

{

cout<<"\nLower Case of string is ="<<strlwr(str);

}


};

int main()

{

clrscr();

int choice;

char ch;

String s;

s.getData();

do

{

cout<<endl<<"1:Reverse String";

cout<<endl<<"2:Convert the string in Uppercase";

cout<<endl<<"3:Convert the string in Lowercase";

cout<<endl<<"4:String Length";

cout<<endl<<"5:Exit";


cout<<endl<<"\nEnter your choice=";

cin>>choice;

switch(choice)

{

case 1:

s.strrev1();

break;

case 2:

s.strupr1();

break;

case 3:

s.strlwr1();

break;

case 4:

s.strlen1();

break;

case 5: exit(0);

break;

default:

cout<<endl<<"Invalid choice";

}

cout<<"\nDo you want to cont...";

cin>>ch;

}while(ch=='y'||ch=='Y');

return 0;

}

No comments:

Post a Comment