Mayil-SB-Internal-Prod / area-of-shapes

0 stars 0 forks source link

Area of triangle produced when running ./triangle is not right #6

Open vikramsubramanian opened 5 months ago

vikramsubramanian commented 5 months ago

Input: Base = 5, Height = 2 Expected Output: Area = 5 Actual Output with Bug: Area = 4.5

mayil-ai[bot] commented 5 months ago

Possible Solution

double areaTriangle(double base, double height) {
    return (base * height) / 2;
}

Code snippets to check

triangle.cpp The function areaTriangle has an incorrect formula for calculating the area of a triangle, which is causing the output to be wrong. https://github.com/Mayil-SB-Internal-Prod/area-of-shapes/blob/2b9f475536430312b5a22932fbda88cf65dda84d/triangle.cpp#L1-L6