-
Notifications
You must be signed in to change notification settings - Fork 0
/
Return_keyword.cpp
40 lines (29 loc) · 958 Bytes
/
Return_keyword.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
#include <iostream>
double square(double length);
double cube(double length);
std::string concatStrings(std::string string1, std::string string2);
int main() {
// return = return a value back to the spot
// where you called the encompassing function
double length;
std::string firstName = "Yutak";
std::string lastName = "Choi";
std::cout << "Enter a length: ";
std::cin >> length;
double area = square(length);
double volume = cube(length);
std::string fullName = concatStrings(firstName, lastName);
std::cout << "Area: " << area << "cm^2\n";
std::cout << "Volume: " << volume << "cm^3\n";
std::cout << "Hello " << fullName << "\n";
return 0;
}
double square(double length) {
return length * length;
}
double cube(double length) {
return length * length * length;
}
std::string concatStrings(std::string string1, std::string string2) {
return string1 + " " + string2;
}