-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem4.sol
More file actions
22 lines (16 loc) · 906 Bytes
/
Copy pathproblem4.sol
File metadata and controls
22 lines (16 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//Problem 4
//Create a Solidity function named evaluate() that takes two integer arguments, a and b.
//The function should subtract the difference of a and b from the sum of a and b and return the result.
//Solution =>
pragma solidity ^0.8.0;
contract challenge4 {
// This line declares the contract called "challenge4".
function evaluate(int a, int b) public pure returns (int){
// This line declares a function called "evaluate".
// The function is marked as "public", which means it can be called from outside the contract.
// The function is also marked as "pure", which means it does not read or modify data from the contract.
// The function takes two parameters of type int called "a" and "b".
// The function returns a value of type int.
return ((a+b) - (a-b)); // This line returns the result of the expression (a+b) - (a-b).
}
}