-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
03_FunctionsIntro.sol
43 lines (33 loc) · 1015 Bytes
/
03_FunctionsIntro.sol
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract FunctionsIntro{
/* Note: All of the function visibility topics will be discussed later. */
// Addition
function add(uint x , uint y) external pure returns (uint){
return x+y;
}
// Subtraction
function sub(uint x , uint y) external pure returns (uint){
return x-y;
}
// Multiplication
function mul(uint x , uint y) external pure returns (uint){
return x*y;
}
// Division
function div(uint x , uint y) external pure returns (uint){
return x/y;
}
// Modulo
function mod(uint x , uint y) external pure returns (uint){
return x%y;
}
// Exponentiation
function exponentiation(uint x , uint y) external pure returns (uint){
return x**y;
}
// This is function overloading; as we have same name function but diff. parameters
function add(uint x , uint y, uint z) external pure returns (uint){
return x+y+z;
}
}