Files
School/Anul 1/Semestrul 1/Programare in C/Homework1/7.c
T
2024-08-31 12:07:21 +03:00

16 lines
496 B
C

//Being given the values of the diagonals of a diamond shape (romb), compute the area and perimeter of the diamond shape.
#include<stdio.h>
#include<math.h>
int main(){
float d1,d2,perimeter,area;
printf("Please enter a number: ");
scanf("%f",&d1);
printf("Please enter another number: ");
scanf("%f",&d2);
perimeter=2*sqrtf(d1*d1+d2*d2);
area=(d1*d2)/2;
printf("The perimeter of a romb with diagonals %.2f and %.2f is: %.2f and the area is: %.2f.\n",d1,d2,perimeter,area);
return 0;
}