-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathP88STRING.cpp
More file actions
50 lines (37 loc) · 1.01 KB
/
P88STRING.cpp
File metadata and controls
50 lines (37 loc) · 1.01 KB
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
48
49
50
// string challenges
// converting entire string into either uppercase or lowercase
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
// string str="fgfgvhg";
// cout<<'a'-'A'; // this is done to check the ascii of difference b/w lower n uppercase value
// convert into upper case
// for (int i = 0; i < str.size(); i++)
// {
// if (str[i] >= 'a' && str[i]<='z')
// {
// str[i] -= 32;
// }
// }
// cout<<str<<endl;
// // convert into lower case
// for (int i = 0; i < str.size(); i++)
// {
// if (str[i] >= 'A' && str[i]<='Z')
// {
// str[i] += 32;
// }
// }
// cout<<str;
// this process can be simplified using TRANSFORM() FUNCTION
string s="vdhwdhjkw";
// uppercase
transform(s.begin(),s.end(),s.begin(),::toupper);
cout<<s<<endl;
// lowercase
transform(s.begin(),s.end(),s.begin(),::tolower);
cout<<s<<endl;
return 0;
}