#includeint main() { sf::FloatRect rect1(10, 10, 50, 50); // creates a FloatRect with position (10,10) and size (50,50) float width = rect1.width; // retrieves the width of the rectangle return 0; }
#includeIn this example, we calculate the area of a rectangle using its width and height values. We use the `std::abs()` function from the math library to ensure that the area value is non-negative. This example does not use any package library.// Required for math functions int main() { float x = 10, y = 20, width = 50, height = 50; float area = std::abs(width * height); // calculates area of the rectangle return 0; }