← Back to Structs
Question 240
Rectangle Struct: Compute the Perimeter
Rectangle Struct: Compute the Perimeter
Define a struct type named Rectangle with integer fields width and height. Create a Rectangle with width 7 and height 3, then print its perimeter, which is 2 times (width plus height), exactly as: Perimeter: 20 followed by a newline. Remember to add width and height first, then multiply by 2.
Expected Output:
Perimeter: 20= newline. The output ends with a newline — print one after the last line.
Hints4 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.