Complete the code to declare a storage variable in Solidity.
uint256 public [1];In Solidity, variables declared at contract level like storedValue are stored in storage by default.
Complete the function to declare a memory array parameter in Solidity.
function processData(uint256[] [1] data) public {}storage for function parameters which causes errors.calldata with memory.Function parameters that are arrays or structs usually use memory to indicate temporary data during function execution.
Fix the error in the function by choosing the correct data location for the string parameter.
function setName(string [1] name) public {}memory unnecessarily which increases gas cost.storage which is invalid for function parameters.For external function parameters, calldata is the recommended data location for strings to save gas and avoid copying.
Fill the blank to create a temporary memory array for the function return. Mappings are always stored in storage.
mapping(address => uint) balances;
function getTopBalances() public view returns (uint[] {{BLANK_2}}) {}memory which is invalid.memory location.Mappings are always stored in storage (no keyword needed). Function return arrays should be declared as memory to hold temporary data.
Fill both blanks to declare a memory struct variable and assign a value.
struct User {
uint id;
string name;
}
User [2] userMemory;
userMemory.id = {{BLANK_3}};memory keyword which is invalid.id.The struct is declared at the contract level. The variable userMemory is declared in memory for temporary use. Assigning 10 to id sets the value.