16 lines
496 B
C
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;
|
|
}
|