← Back to Structs
Question 242
Circle Struct: Radius and Diameter
Circle Struct: Radius and Diameter
Define a struct type named Circle with a single integer field radius. Create a Circle with radius 5, then print its radius and its diameter (radius times 2) exactly as: Radius: 5, Diameter: 10 followed by a newline. This shows that a struct can hold just one field, and that you can derive new values from it.
Expected Output:
Radius: 5, Diameter: 10= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Structs
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.