M
M
// SPDX-License-Identifier: MIT
pragma solidity >= 0.5.0 < 0.9.0;
contract local {
uint public count;
constructor(uint new_count) {
count=new_count;
}
}
//if_else_in_solidity
// SPDX-License-Identifier: MIT
pragma solidity >= 0.5.0 < 0.9.0;
contract array {
function check(int a) public pure returns (string memory) {
string memory value;
if (a>0) {
value="Greater than zero";
}
else if (a==0) {
value="Equal to zero";
}
else {
value="Less than zero";
return value;
}
}
}
//loops_in_solidity
// SPDX-License-Identifier: MIT
pragma solidity >= 0.5.0 < 0.9.0;
contract loops {
uint[3] public arr;
uint public count;
function whileloop() public
{
while (count < arr.length)
{
arr[count]=count;
count++;
}
}
function forloop() public {
for (uint i=count; i<arr.length; i++) {
arr[count]=count;
count++;
}
}
}