-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path53. Change Case Of Letters.cpp
47 lines (47 loc) · 1.13 KB
/
53. Change Case Of Letters.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s, s1; int x;
cout<<"Enter a string in any case"<<endl;
getline(cin,s);
cout<<"Enter 1 to change the string into UPPER case OR Enter 2 to change string into LOWER case"<<endl;
cin>>x;
string::iterator p;
switch(x)
{
case 1:
for(p=s.begin(); p!=s.end(); p++)
{
if(*p>='a' && *p<='z')
{
s1= *p-32;
cout<<s1;
}
else
{
s1=*p;
cout<<s1;
}
}
break;
case 2:
for(p=s.begin(); p!=s.end(); p++)
{
if(*p>='A' && *p<='Z')
{
s1=*p+32;
cout<<s1;
}
else
{
s1=*p;
cout<<s1;
}
}
break;
default: cout<<"Please input a valid choice"<<endl;
}
return 0;
}