Created
August 14, 2023 14:56
-
-
Save Ifeanyi-Ani/06cc6210d37945abd19336b43ece16c2 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.21+commit.d9974bed.js&optimize=false&runs=200&gist=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.9; | |
contract loopAndFunctionChallenge{ | |
// function that takes two number and add them together | |
function addTwoNumber(uint a, uint b) external pure returns (uint) { | |
return a + b; | |
} | |
// function that substract two given number | |
function substractTwoNumber(uint a, uint b) external pure returns (uint){ | |
//checking to make sure it does not return negative number | |
if (a >= b) { | |
return a - b; | |
} | |
return b - a; | |
} | |
//function that multiply two given number | |
function multiplyTwoNumber(uint a, uint b)external pure returns (uint) { | |
return a * b; | |
} | |
//function that divide two given number | |
function divideTwoNumber(uint a, uint b)external pure returns (uint) { | |
if(b != 0){ | |
return a / b; | |
} | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment