Recall & Review
beginner
What is the purpose of an if-else statement?
An if-else statement lets a program choose between two paths: one if a condition is true, and another if it is false.
Click to reveal answer
beginner
How do you write a simple if-else statement in Solidity?
You write it like this:<br>
if (condition) {<br> // code if true<br>} else {<br> // code if false<br>}Click to reveal answer
beginner
What happens if the if condition is false and there is no else block?
The program skips the if block and continues with the code after it, doing nothing inside the if.
Click to reveal answer
intermediate
Can you have multiple conditions checked in an if-else structure?
Yes, by using else if blocks between if and else, you can check many conditions in order.
Click to reveal answer
intermediate
Why are if-else statements important in blockchain smart contracts?
They let contracts make decisions, like checking if a user has enough balance before sending tokens.Click to reveal answer
What does an if-else statement do in a program?
✗ Incorrect
An if-else statement lets the program pick one action if a condition is true, and another if false.
In Solidity, what keyword starts the condition check?
✗ Incorrect
The keyword 'if' starts the condition check in Solidity and many other languages.
What happens if the if condition is false and there is no else block?
✗ Incorrect
Without an else block, if the condition is false, the program just skips the if block.
How can you check multiple conditions in an if-else structure?
✗ Incorrect
You use else if blocks to check multiple conditions in order.
Why are if-else statements useful in smart contracts?
✗ Incorrect
If-else statements let smart contracts decide what to do based on conditions like balances or permissions.
Explain how an if-else statement controls the flow of a program.
Think about choosing between two roads based on a sign.
You got /4 concepts.
Describe a real-life example where an if-else statement would be useful in a blockchain smart contract.
Imagine sending money only if you have enough.
You got /4 concepts.