Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitscript authored Sep 29, 2022
1 parent 83526e3 commit 13896b9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 17Day-Search.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.9.0;

contract Day5 {
//Create a function search(array, length of array,element to search) . This search() will take three arguments - a dynamic uint type array ,length of the array, element that we need to search.

function search(
int256[] memory arr,
uint256 size,
int256 toSearch
) public pure returns (uint256) {
for (uint256 i = 0; i < size; i++) {
if (arr[i] == toSearch) {
return 1; //if element is found
}
}
return 0; //if element is not found
}
}

0 comments on commit 13896b9

Please sign in to comment.