Answers for "function in solidity"

1

function in solidity

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;
    }
}
Posted by: Guest on February-25-2022
0

function in solidity

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;
   }
}
Posted by: Guest on March-29-2022
0

solidity function

// 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;
   }
Posted by: Guest on March-08-2022

Browse Popular Code Answers by Language