Search
 
SCRIPT & CODE EXAMPLE
 

CPP

C++ Area of Triangle

    //uisng Heron's Formula
    float first, second, third, semiperimeter, area;

    cout << "Input the first side of the triangle: ";
    cin >> first;
    cout << "Input the first side of the triangle: ";
    cin >> second;
    cout << "Input the third side of the triangle: ";
    cin >> third;

    semiperimeter = (first + second + third)/2;
    area = sqrt (semiperimeter*(semiperimeter-first)*(semiperimeter-second)*(semiperimeter-third));

    cout << "The area of the triangle is " << area << endl;
Comment

. Write a C++ program to calculate area of a Triangle

#include<iostream>
using namespace std;
int main()
{
    float b, h, area;
    cout<<"Enter Base length of Triangle: ";
    cin>>b;
    cout<<"Enter Height length of Triangle: ";
    cin>>h;
    area = 0.5*b*h;
    cout<<"
Area = "<<area;
    cout<<endl;
    return 0;
}
Comment

. Write a C++ program to calculate area of a Triangle

#include<iostream>
using namespace std;
int main()
{
    float b, h, area;
    cout<<"Enter Base length of Triangle: ";
    cin>>b;
    cout<<"Enter Height length of Triangle: ";
    cin>>h;
    area = 0.5*b*h;
    cout<<"
Area = "<<area;
    cout<<endl;
    return 0;
}
Comment

. Write a C++ program to calculate area of a Triangle

#include<iostream>
using namespace std;
int main()
{
    float b, h, area;
    cout<<"Enter Base length of Triangle: ";
    cin>>b;
    cout<<"Enter Height length of Triangle: ";
    cin>>h;
    area = 0.5*b*h;
    cout<<"
Area = "<<area;
    cout<<endl;
    return 0;
}
Comment

. Write a C++ program to calculate area of a Triangle

#include<iostream>
using namespace std;
int main()
{
    float b, h, area;
    cout<<"Enter Base length of Triangle: ";
    cin>>b;
    cout<<"Enter Height length of Triangle: ";
    cin>>h;
    area = 0.5*b*h;
    cout<<"
Area = "<<area;
    cout<<endl;
    return 0;
}
Comment

Write a c++ Program to calculate the area of an equilateral triangle.

#include<iostream>
#include<math.h>
using namespace std;
int main(){
    float side, area;
    cout<<" Input the value of the side of the equilateral triangle: ";
    cin>>side;

    area = (sqrt(3) / 4) * (side * side);

    cout<<" The area of equilateral triangle is: "<<area<<endl;
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ garbage collection 
Cpp :: Euler constant 
Cpp :: volumeof a sphere 
Cpp :: Reverse a linked list geeksforgeeks in c++ 
Cpp :: variadic template in c++ 
Cpp :: Ninja c++ 
Cpp :: cin does not wait for input 
Cpp :: for auto c++ 
Cpp :: cpp malloc 
Cpp :: c++ include < vs "" 
Cpp :: async multi thread 
Cpp :: cpp vector popback 
Cpp :: runtime 
Cpp :: right shift in c++ 
Cpp :: options select from array 
Cpp :: C++ function inside main 
Cpp :: split text c++ 
Cpp :: How to see gateway on linux 
Cpp :: C++ insert character 
Cpp :: sstream c++ 
Cpp :: summation of numbers using function 
Cpp :: c++ how to do a pointer char to take varols from keyboard 
Cpp :: how to do if command in c++ 
Cpp :: c++ round number to 2 decimal places 
Cpp :: find n unique integers sum up to zero 
Cpp :: c++ program to convert fahrenheit to kelvin 
Cpp :: find substring after character 
Cpp :: CodeChef Starters 30 Division 4 (Rated) Swapping Chefs Way 
Cpp :: Password codechef solution in c++ 
Cpp :: bnchch 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =