-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example.cpp
51 lines (40 loc) · 932 Bytes
/
Example.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
41
42
43
44
45
46
47
48
49
50
51
/**
* @file Example.cpp
*
* @brief C++ Program to demonstrate working of default argument.
*
* @author Saif Ullah Ijaz
*
*/
#include <iostream>
using namespace std;
// FUNCTION PROTOTYPE (DECLARATION)
/** function that prints a character multiple times.
*
* @param c The input character to be printed.
* @param n The no. of times to be printed.
*
* @return void.
*/
void display(char = '*', int = 1);
// function main begins program execution
int main() {
cout << "No argument passed:\n";
display();
cout << "\n\nFirst argument passed:\n";
display('#');
cout << "\n\nBoth argument passed:\n";
display('$', 5);
system("pause");
return 0;
}
// end main
// FUNCTION DEFINITION
// function that displays the input character desired no. of times
void display(char c, int n) {
for (int i = 1; i <= n; ++i) {
cout << c;
}
cout << endl;
}
// end function display