-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexp-1-14.c
More file actions
38 lines (31 loc) · 866 Bytes
/
exp-1-14.c
File metadata and controls
38 lines (31 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*************************************************************************
> File Name: exp-1-14.c
> Author: xiaoxiaoh
> Mail: xiaoxxhao@gmail.com
> Created Time: Tue Jun 27 16:50:31 2017
************************************************************************/
/*
* Write a C program to calculate area of an equilateral triangle.
*
* Example
*
* Input
* Enter side of the equilateral triangle: 10
*
* Output
* Area of equilateral triangle = 43.3 sq. units
*
*/
#include <stdio.h>
#include <math.h> //used for sqrt() function
int main()
{
float side, area;
/* Input side of equilateral triangle */
printf("Enter side of an equilateral triangle: ");
scanf("%f", &side);
/* Calculate area of equilateral triangle */
area = (sqrt(3) / 4) * (side * side);
printf("Area of equilateral triangle is %.2lf\n", area);
return 0;
}