-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathdefaultArgs.cpp
More file actions
47 lines (33 loc) · 1.35 KB
/
defaultArgs.cpp
File metadata and controls
47 lines (33 loc) · 1.35 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
//*****************************************************************************************************
//
// This program demonstrates the use of default arguments in a function.
//
//*****************************************************************************************************
#include <iostream>
using namespace std;
//*****************************************************************************************************
void displayMsg(const char msg[] = "Decide. Commit. Succeed.", char symbol = ' ', int num = 10);
//*****************************************************************************************************
int main() {
displayMsg("I will decide.", '*', 15);
displayMsg("I will commit.", '+');
displayMsg("I will succeed.");
displayMsg();
return 0;
}
//*****************************************************************************************************
void displayMsg(const char msg[], char symbol, int num) {
for (int i = 0; i < num; ++i)
cout << symbol;
cout << msg;
for (int i = 0; i < num; ++i)
cout << symbol;
cout << endl;
}
//*****************************************************************************************************
/*
***************I will decide.***************
++++++++++I will commit.++++++++++
I will succeed.
Decide. Commit. Succeed.
*/