-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC++ Function Syntax Parameters.cpp
More file actions
81 lines (62 loc) · 1.56 KB
/
C++ Function Syntax Parameters.cpp
File metadata and controls
81 lines (62 loc) · 1.56 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
[PROGRAM] : function Parameters and Arguments
[AUTHOR] : Saddam Arbaa
[Email] : <saddamarbaas@gmail.com>
we can pass data(Information) to functions as a parameter. */
#include <iostream>
using namespace std;
// Function declaration
void myFunction(string name);
// Function declaration
int min(int num1, int num2);
// function declaration
int max(int num1, int num2);
// the main Function
int main()
{
// local variable declaration:
int x = 1;
int y = 2;
int m, n;
// calling a function to get max value.
m = max(x, y);
cout << "Max value is : " << m << endl;
// calling a function to get min value.
n = min(x, y);
cout << "min value is : " << n << endl;
// call the function 5 times
myFunction("Jhon");
myFunction("Liam");
myFunction("Adam");
myFunction("Ali");
myFunction("Mr Bob");
return 0;// signal to operating system everything works fine
}/** End of main function */
// void Function definition
void myFunction(string name)
{
// the body of the function (definition)
cout << "Hello dear : " << name << endl;
}
// function returning the max between two numbers
int max(int num1, int num2)
{
// local variable declaration
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result; // return max
}
// function returning the min between two numbers
int min(int num1, int num2)
{
// local variable declaration
int result;
if (num1 < num2)
result = num1;
else
result = num2;
return result; // return min
}