Draw a simple memory diagram showing how a program stores three variables: an integer 'age' with value 25, a float 'height' with value 1.75, and a string 'name' with value 'Ana'. Label the memory addresses and values clearly.
0
0
Memory management basics in Intro to Computing - Draw & Build Visually
Draw This - beginner
10 minutes
Hint 1
Hint 2
Hint 3
Grading Criteria
Memory addresses labeled clearly
Variables labeled with correct names
Values correctly shown for each variable
String characters shown in sequence with null terminator
Memory boxes represent consistent size (e.g., 1 byte for characters, 4 bytes for int/float)
Diagram shows separate memory locations for each variable
Solution
Memory Diagram: +---------+---------+---------+---------+---------+---------+---------+---------+ | Address | 0x1000 | 0x1004 | 0x1008 | 0x1009 | 0x100A | 0x100B | 0x100C | +---------+---------+---------+---------+---------+---------+---------+---------+ | Value | 25 | 1.75 | 'A' | 'n' | 'a' | '\0' | | +---------+---------+---------+---------+---------+---------+---------+---------+ Explanation: - 'age' is an integer stored at address 0x1000 with value 25. - 'height' is a float stored at address 0x1004 with value 1.75. - 'name' is a string stored starting at address 0x1008 with characters 'A', 'n', 'a', and a null terminator '\0' at 0x100B. - Each box represents 1 byte of memory. - The string ends with a special '\0' character to mark its end.
This memory diagram shows how three variables are stored in memory.
Each box represents 1 byte of memory with a unique address.
The integer 'age' uses 4 bytes starting at address 0x1000 and stores the value 25.
The float 'height' uses the next 4 bytes starting at 0x1004 and stores 1.75.
The string 'name' starts at 0x1008 and uses several bytes to store each character: 'A' at 0x1008, 'n' at 0x1009, 'a' at 0x100A, and a null character '\0' at 0x100B to mark the end of the string.
This shows how different types use memory and how strings are stored as sequences of characters ending with a special marker.
Variations - 2 Challenges
[beginner] Draw a memory diagram showing how a program stores two variables: a boolean 'isStudent' with value true and an integer 'score' with value 88. Label the memory addresses and values.
[intermediate] Draw a memory diagram showing how a program stores an array of 4 integers: [10, 20, 30, 40]. Label each element's memory address and value.