Skip to content

Instantly share code, notes, and snippets.

@Ifeanyi-Ani
Created August 14, 2023 14:56
Show Gist options
  • Save Ifeanyi-Ani/06cc6210d37945abd19336b43ece16c2 to your computer and use it in GitHub Desktop.
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=
// 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