-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path08-functions.cpp
More file actions
47 lines (32 loc) · 1.06 KB
/
08-functions.cpp
File metadata and controls
47 lines (32 loc) · 1.06 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
#include <iostream>
#include <cmath>
using namespace std;
// Nota: Al igual que ocurre en C, si una función se implementa después de la función principal "main",
// debe indicarse la firma o cabecera de la función antes de la función principal "main". Si se implementa,
// directamente antes de la función "main", no hay que indicar la firma o cabecera de la función.
void sayHi();
void sayHiWithParameters1(string name) {
cout << "Hello, " << name << endl;
}
void sayHiWithParameters2(string name, int age) {
cout << "Hello, " << name << '.' << endl;
cout << "You are " << age << " years old." << endl;
}
double cube(double num) {
return pow(num, 3);
}
int main() {
sayHi();
cout << "-------------\n";
sayHiWithParameters1("John");
cout << "-------------\n";
sayHiWithParameters2("Mike", 33);
sayHiWithParameters2("Nicole", 60);
sayHiWithParameters2("Tom", 17);
cout << "-------------\n";
cout << "The cube of " << 5 << " is: " << cube(5);
return 0;
}
void sayHi() {
cout << "Hello User" << endl;
}