Create a c structure to represent a rectangle with width and height. Create a rectangle object and find the perimeter of the rectangle
#include <stdio.h>
typedef struct {
int width;
int height;
} Rect;
int main()
{
Rect rect;
rect.width = 10;
rect.height = 20;
printf("Perimeter: %d\n", (rect.width + rect.height) * 2);
return 0;
}
Comments
Leave a comment