function in solidity

The solution for “function in solidity” can be found here. The following code will assist you in solving the problem.

pragma solidity >=0.7.0 <0.9.0;

contract simpleStorage {
uint storeData;

//set and get function
//public enables visibility so that we can call this outside contract
function set(uint x) public{
storeData= x;
}

//view means it values is only read not to modify
function get() public view returns(uint){
return storeData;
}
}pragma solidity ^0.5.0;

contract Test {
function getResult() public view returns(uint){
uint a = 1; // local variable
uint b = 2;
uint result = a + b;
return result;
}
} // Defining function to calculate sum of 2 numbers
function add() public view returns(uint){
uint num1 = 10;
uint num2 = 16;
uint sum = num1 + num2;
return sum;
}

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts