forked from rathoresrikant/HacktoberFestContribute
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLowerToUpper.cpp
35 lines (27 loc) · 1.03 KB
/
LowerToUpper.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
// File name: LowerToUpper.cpp
// Author: Viet Than
// Email: [email protected], [email protected]
// Repository owner: rathoresrikant
// Repository name: HacktoberFestContribute
// Honor statement: I attest that I understand the honor code for this class
// and have neither given nor received any unauthorized aid on this assignment.
//
// Issue: In a string, convert all the lowercase letters to upper case and vice versa.
#include <iostream>
#include <string>
int main(){
std::string input;
std::cout << "This function will turn characters in string from lowercase"
"to uppercase and vice versa.\nPlease input string:\n";
std::cin >> input;
std::cout << "The value you entered is: " << input << std::endl;
for (char &i : input) {
if (islower(i)){
i = static_cast<char>(toupper(i));
} else {
i = static_cast<char>(tolower(i));
}
}
std::cout << "The resulting changed string is: "<< input;
return 0;
}