0
0
Blockchain / Solidityprogramming~10 mins

Structs in Blockchain / Solidity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a struct named Person with a string name.

Blockchain / Solidity
struct Person {
    string [1];
}
Drag options to blanks, or click blank then click option'
Abalance
Bage
Caddress
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong field name like 'age' or 'address' when the task asks for 'name'.
Forgetting to specify the field name.
2fill in blank
medium

Complete the code to declare a variable of type Person named user.

Blockchain / Solidity
Person [1];
Drag options to blanks, or click blank then click option'
Auser
Baccount
Cclient
Dperson
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different variable name like 'person' or 'account'.
Forgetting the semicolon at the end (not part of the blank but common error).
3fill in blank
hard

Fix the error in the struct definition by completing the missing type for the field age.

Blockchain / Solidity
struct Person {
    string name;
    [1] age;
}
Drag options to blanks, or click blank then click option'
Abool
Buint
Cstring
Daddress
Attempts:
3 left
💡 Hint
Common Mistakes
Using string or bool for age.
Using address which is for blockchain addresses.
4fill in blank
hard

Fill both blanks to create a struct named Car with a string model and a uint year.

Blockchain / Solidity
struct [1] {
    [2] model;
    uint year;
}
Drag options to blanks, or click blank then click option'
ACar
BPerson
Cstring
Duint
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong struct name like 'Person'.
Using wrong type for model like 'uint'.
5fill in blank
hard

Fill all three blanks to create a struct named Book with a string title, string author, and uint pages.

Blockchain / Solidity
struct [1] {
    [2] title;
    [3] author;
    uint pages;
}
Drag options to blanks, or click blank then click option'
ABook
Bstring
Duint
Attempts:
3 left
💡 Hint
Common Mistakes
Using different struct name.
Using wrong types for title or author.