Complete the code to declare a view function that returns a stored number.
function getNumber() public [1] returns (uint) { return storedNumber; }
The view keyword indicates the function reads state but does not modify it.
Complete the code to declare a pure function that returns the sum of two numbers.
function add(uint a, uint b) public [1] returns (uint) { return a + b; }
The pure keyword means the function neither reads nor modifies the blockchain state.
Fix the error in the function declaration to make it a view function.
function getBalance() public [1] returns (uint) { return balance; }
The function reads the state variable balance, so it must be marked as view.
Fill both blanks to create a pure function that returns the product of two numbers.
function multiply(uint x, uint y) public [1] returns (uint) { return x [2] y; }
The function does not read or modify state, so it is pure. The multiplication operator is *.
Fill all three blanks to create a view function that returns the length of a stored string.
function getStringLength() public [1] returns (uint) { return [2].[3]; }
The function reads the stored string variable storedString and returns its length. It must be marked view.