Skip to content

Commit 76d237b

Browse files
authored
Merge pull request The-Streamliners#34 from offthegrid-mike/main
Create toUpper.cpp
2 parents 4511f3a + a5d22e8 commit 76d237b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

String/toUpper.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// C++ program to change all char from lower to uppper
2+
#include <iostream>
3+
using namespace std;
4+
5+
string toUpper(const string s) {
6+
string result = "";
7+
8+
for (auto c : s) {
9+
if ((c >= 'a') && (c <= 'z'))
10+
c -= 32;
11+
result.push_back(c);
12+
}
13+
14+
return result;
15+
}
16+
17+
18+
int main(int argc, const char * argv[]) {
19+
20+
cout << toUpper("123z!2PAaa");
21+
22+
return 0;
23+
}

0 commit comments

Comments
 (0)