Skip to content

luc061.c

Problem Statement

The area of a triangle can be computed by the sine law. Given 6 triangular pieces of land (a, b, angle), find their area and determine which is largest.

Metadata

Property Detail
Author Amit Dutta amitdutta4255@gmail.com
Date 08 Feb 2026
License MIT License (See the LICENSE file for details)
Difficulty Beginner (index: 1 / 10)

Concepts

Beta Feature

This concept detection system is still in beta and may occasionally show incorrect or incomplete results.

  • Array
  • Pointers

Actions

Raw View on GitHub

You can print or save this file by opening Raw and using your browser.

Source Code

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

int main()
{
    // Data arrays
    double a[] = {137.4, 155.2, 149.3, 160.0, 155.6, 149.7};
    double b[] = {80.9, 92.62, 97.93, 100.25, 68.95, 120.0};
    double angle[] = {0.78, 0.89, 1.35, 9.00, 1.25, 1.75}; // Assuming radians based on values < 2.0. 9.00 is treated as literal.

    double area, max_area = 0.0;
    int i, max_index = -1;

    printf("Plot No.\tArea\n");
    printf("------------------------\n");

    for (i = 0; i < 6; i++)
    {
        // Area = 1/2 * a * b * sin(angle)
        area = 0.5 * a[i] * b[i] * sin(angle[i]);

        printf("%d\t\t%.2f\n", i + 1, area);

        if (area > max_area)
        {
            max_area = area;
            max_index = i + 1;
        }
    }

    printf("\nLargest Plot is No. %d with Area: %.2f\n", max_index, max_area);

    return 0;
}

Explanation

Explain with AI

Copy the prompt below and paste it into any AI assistant.

    You are explaining a C programming code to a beginner.

    STRICT RULES:

    - Only use the given code. Do NOT assume anything not present.

    - Do NOT add extra examples.

    - Keep explanation clear and short.

    - If something is unclear, say "Not clear from code".

    - Follow the exact format below. Do NOT change headings.

    FORMAT:

    [START]

    ## What it does

    (Explain the overall purpose in 1-2 sentences)

    ## Step-by-step

    (Explain how the code works in steps, simple language)

    ## Key Concepts

    (List concepts like loop, condition, function, etc.)

    ## Notes

    (Mention any limitations, errors, or assumptions)

    [END]

    CODE (luc061.c):

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

    int main()
    {
        // Data arrays
        double a[] = {137.4, 155.2, 149.3, 160.0, 155.6, 149.7};
        double b[] = {80.9, 92.62, 97.93, 100.25, 68.95, 120.0};
        double angle[] = {0.78, 0.89, 1.35, 9.00, 1.25, 1.75}; // Assuming radians based on values < 2.0. 9.00 is treated as literal.

        double area, max_area = 0.0;
        int i, max_index = -1;

        printf("Plot No.\tArea\n");
        printf("------------------------\n");

        for (i = 0; i < 6; i++)
        {
            // Area = 1/2 * a * b * sin(angle)
            area = 0.5 * a[i] * b[i] * sin(angle[i]);

            printf("%d\t\t%.2f\n", i + 1, area);

            if (area > max_area)
            {
                max_area = area;
                max_index = i + 1;
            }
        }

        printf("\nLargest Plot is No. %d with Area: %.2f\n", max_index, max_area);

        return 0;
    }