#include <stdio.h>
int main() {
int side;
float area, perimeter;
printf("Enter side length: ");
// ตรวจสอบว่าค่าที่กรอกเป็นค่าบวกหรือไม่
if(side <= 0) {
printf("Side length must be greater than zero.\n"); } else {
// คำนวณพื้นที่และเส้นรอบวง
area = side * side;
perimeter = 4 * side;
printf("Area = %.3f\n", area
); printf("Perimeter = %.3f\n", perimeter
); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpIHsKICAgIGludCBzaWRlOwogICAgZmxvYXQgYXJlYSwgcGVyaW1ldGVyOwogICAgCiAgICBwcmludGYoIkVudGVyIHNpZGUgbGVuZ3RoOiAiKTsKICAgIHNjYW5mKCIlZCIsICZzaWRlKTsKICAgIAogICAgLy8g4LiV4Lij4Lin4LiI4Liq4Lit4Lia4Lin4LmI4Liy4LiE4LmI4Liy4LiX4Li14LmI4LiB4Lij4Lit4LiB4LmA4Lib4LmH4LiZ4LiE4LmI4Liy4Lia4Lin4LiB4Lir4Lij4Li34Lit4LmE4Lih4LmICiAgICBpZihzaWRlIDw9IDApIHsKICAgICAgICBwcmludGYoIlNpZGUgbGVuZ3RoIG11c3QgYmUgZ3JlYXRlciB0aGFuIHplcm8uXG4iKTsKICAgIH0gZWxzZSB7CiAgICAgICAgLy8g4LiE4Liz4LiZ4Lin4LiT4Lie4Li34LmJ4LiZ4LiX4Li14LmI4LmB4Lil4Liw4LmA4Liq4LmJ4LiZ4Lij4Lit4Lia4Lin4LiHCiAgICAgICAgYXJlYSA9IHNpZGUgKiBzaWRlOwogICAgICAgIHBlcmltZXRlciA9IDQgKiBzaWRlOwogICAgICAgIAogICAgICAgIHByaW50ZigiQXJlYSA9ICUuM2ZcbiIsIGFyZWEpOwogICAgICAgIHByaW50ZigiUGVyaW1ldGVyID0gJS4zZlxuIiwgcGVyaW1ldGVyKTsKICAgIH0KICAgIAogICAgcmV0dXJuIDA7Cn0=