-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC++ Function Syntax Return Values.cpp
More file actions
66 lines (51 loc) · 1.34 KB
/
C++ Function Syntax Return Values.cpp
File metadata and controls
66 lines (51 loc) · 1.34 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
/**
[PROGRAM] : C++ The Return Keyword
[AUTHOR] : Saddam Arbaa
[Email] : <saddamarbaas@gmail.com> */
#include <iostream>
using namespace std;
// Function declaration
int SUM(int a, int b) ;
// Function declaration
int SUB(int a, int b) ;
// Function declaration
int MUL(int a, int b) ;
// the main Function
int main()
{
//variables declaration
int num1 = 5;
int num2 = 5;
int sum = SUM(num1, num2); // call the SUM function
int sub = SUB(num1, num2); // call the SUB function
int mult = MUL(num1, num2); // call the MUL function
// print the values
cout << "The sum is " << sum << endl;
cout << "The Multiplication is " << mult << endl;
cout << "The subtraction is " << sub << endl;
return 0; // signal to operating system program ran fine
}/** End of main function */
// function to calculate sum and returned
int SUM(int a, int b)
{
int s = a + b;
// method using the return
// statement to return a value
return s;
}
// function to calculate subtraction and returned
int SUB(int a, int b)
{
int s = a - b;
// method using the return
// statement to return a value
return s;
}
// function to calculate Multiplication and returned
int MUL(int a, int b)
{
int s = a * b;
// method using the return
// statement to return a value
return s;
}