0
0
Blockchain / Solidityprogramming~5 mins

Function declaration and syntax in Blockchain / Solidity - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a function in blockchain programming?
A function is a reusable block of code that performs a specific task within a smart contract or blockchain program.
Click to reveal answer
beginner
How do you declare a function in Solidity?
You declare a function using the <code>function</code> keyword, followed by the function name, parentheses for parameters, and curly braces for the function body.<br>Example: <code>function greet() public { }</code>
Click to reveal answer
beginner
What does the public keyword mean in a function declaration?
It means the function can be called both inside and outside the smart contract, making it accessible to anyone interacting with the contract.
Click to reveal answer
beginner
What is the purpose of function parameters?
Parameters let you send information into a function so it can use that data to perform tasks or calculations.
Click to reveal answer
intermediate
How do you specify the return type of a function in Solidity?
You add a <code>returns</code> keyword after the parameter list with the type inside parentheses.<br>Example: <code>function getValue() public view returns (uint)</code>
Click to reveal answer
Which keyword is used to declare a function in Solidity?
Amethod
Bfunction
Cfunc
Ddef
What does the public keyword in a function declaration mean?
AFunction is private
BFunction can only be called internally
CFunction can be called externally and internally
DFunction is deprecated
How do you specify a function returns a value in Solidity?
AUsing <code>returns</code> keyword
BUsing <code>output</code> keyword
CUsing <code>returnType</code> keyword
DNo special keyword needed
Which symbol encloses the function body in Solidity?
A<>
B()
C[]
D{}
What is the purpose of function parameters?
ATo send data into a function
BTo store data permanently
CTo declare variables globally
DTo stop function execution
Explain how to declare a function in Solidity including visibility and return type.
Think about the parts you need to write a complete function.
You got /6 concepts.
    Describe the role of function parameters and how they affect function behavior in blockchain programming.
    Consider how you give information to a function.
    You got /4 concepts.