C Program to Calculate Area of Equilatral Triangle

C Program for Beginners : Area of Square

#include<stdio.h>
#include<math.h>

int main()
{
int side;
float area,r_4;

r_4 = sqrt(3) / 4 ;

printf("nEnter the Length of Side : ");
scanf("%d",&side);

area = r_4 * side * side ;

printf("nArea of Equilateral Triangle : %f",area);
return(0);
}
Output :
Enter the Length of Side : 5
Area of Equilateral Triangle : 10.82

Properties of Equilateral Triangle :

  1. Equilateral triangle is a triangle in which all three sides are equal .
  2. All angles are of measure 60 degree
  3. A three-sided regular polygon

Formula to Calculate Area of Equilateral Triangle :

Explanation of Program :

First of all we have to find the value of Root 3 / 2. So we have used following statement to compute the value.
r_4 = sqrt(3) / 4 ;
Now after computing the value of the Root 3 by 2 we have multiplied it by Square of the side.
area = r_4 * side * side ;
C Program to Calculate Area and Circumference of circle

C Program to Calculate Area and Circumference of circle

C Program to find area and circumference of circle

#include<stdio.h>

int main()
{
int rad;
float PI=3.14,area,ci;

printf("nEnter radius of circle: ");
scanf("%d",&rad);

area = PI * rad * rad;
printf("nArea of circle : %f ",area);

ci = 2 * PI * rad;
printf("nCircumference : %f ",ci);

return(0);
}

Output :

Enter radius of a circle : 1
Area of circle : 3.14
Circumference  : 6.28

Explanation of Program :

In this program we have to calculate the area and circumference of the circle. We have following 2 formulas for finding circumference and area of circle.
Area of Circle = PI * R * R
and
Circumference of Circle = 2 * PI * R
In the above program we have declared the floating point variable PI whose value is defaulted to 3.14.We are accepting the radius from user.
printf("nEnter radius of circle: ");

C Program to Calculate Area of Scalene Triangle

C Program to Find Area of Scalene Triangle :

#include<stdio.h>

int main()
{
int s1,s2,angle;
float area;

printf("nEnter Side1 : ");
scanf("%d",&s1);

printf("nEnter Side2 : ");
scanf("%d",&s2);

printf("nEnter included angle : ");
scanf("%d",&angle);

area = (s1 * s2 * sin((M_PI/180)*angle))/2;

printf("nArea of Scalene Triangle : %f",area);
return(0);
}

Output :

Enter Side1 : 3
Enter Side2 : 4
Enter included angle : 30
Area of Scalene Triangle : 3.000000

C Program for Beginners : Area of Scalene Triangle

C Program to find Area of Scalane Triangle

Properties of Scalene Triangle :

  1. Scalene Triangle does not have sides having equal length.
  2. No angles of Scalene Triangle are equal.
  3. To calculate area we need at least two sides and the angle included by them.

Formula to Find Area of Scalene Triangle :

Explanation and Program Logic :

Part 1 : M_PI

sin((M_PI/180)*angle)
  • It is Constant defined in math.h Header File
  • It contain value = 3.14 in short instead of writing 3.14 write directly M_PI.

Part 2 : ( M_PI / 180 ) * angle

  • We are accepting angle in degree.
  • C function sin takes argument in radian , so to convert angle into radian we are purposefully writing above statement.

Part 3 : sin function

  • It computes sine of an angle