In this tutorial you will learn about the C Program to Find Area of an Isosceles Triangle and its application with practical example.
C Program to Find Area of an Isosceles Triangle
In this tutorial, we will learn to create a C program that will Find the Area of an Isosceles Triangle in C programming.
Prerequisites
Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- While loop in C programming.
- Conditional Statements in C programming.
What is an Isosceles triangle?
In geometry, an isosceles triangle is a triangle that has two sides of equal length. The two sides of an equilateral triangle are equal so it can also be classified as an isosceles triangle.
Algorithm:-
1 2 3 4 5 6 7 8 9 |
1. Declaring the required variables for the program. 2. Taking the input size of the side of the triangle. 3. Calculating the area of the <strong>Isosceles </strong>triangle using the code. 4. Printing the area of an <strong>Isosceles </strong>triangle. 5. End the program. |
Program description that will print the area of an Isosceles Triangle:-
In today’s tutorial, we will create a program, that will find the area of an Isosceles triangle using C programming. First, take the input common size of the side of the isosceles triangle by the user. Now, will take the size of another side. Then we will calculate the area of that triangle using the mathematical expression. At last, we will print the area of an isosceles triangle.
Program Code:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#include <stdio.h>//including the header files #include <math.h>//including the header files int main() { //Declaring the required variable for the program. float x, y, iares; //x,y it will hold the input values for the sides. //iares it will hold the calculated value of area of the triangle // Taking the input for the Same Sides length first printf("Enter Isosceles Triangle Length of a Side = "); scanf("%f",&x);//Scanning the input common length side. //Taking the size of another side. printf("Enter Isosceles Triangle Other Side = "); scanf("%f",&y);//Scanning the other side //Calculating the area of the isosceles triangle. iares = (y * sqrt((4 * x * x) - (y * y)))/4; //Printing the area of the isosceles triangle. printf("The Area of the Isosceles Triangle = %.3f\n", iares); return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- x = it will hold the value for the input common size of the side for the triangle.
- y = it will hold the value for the input size of the other side for the triangle.
- iares = it will hold the integer value for the area of a triangle.
Input the size of the side of the triangle.
Code to calculate the area of the triangle.
Printing output the area of an isosceles triangle.