luc061.c (1382B)
1 /* 2 * Author : Amit Dutta <amitdutta4255@gmail.com> 3 * Date : 08 Feb 2026 4 * Repo : https://github.com/notamitgamer/bsc 5 * License : MIT License (See the LICENSE file for details) 6 */ 7 8 /* 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. 9 */ 10 11 /* Let Us C, Chap- 13 (Arrays), Qn No.: B(g) */ 12 13 /* This file is auto-generated by a bot. */ 14 /* This code is not compiled; it is for reference only. */ 15 16 17 #include <stdio.h> 18 #include <math.h> 19 #include <stdlib.h> 20 21 int main() 22 { 23 // Data arrays 24 double a[] = {137.4, 155.2, 149.3, 160.0, 155.6, 149.7}; 25 double b[] = {80.9, 92.62, 97.93, 100.25, 68.95, 120.0}; 26 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. 27 28 double area, max_area = 0.0; 29 int i, max_index = -1; 30 31 printf("Plot No.\tArea\n"); 32 printf("------------------------\n"); 33 34 for (i = 0; i < 6; i++) 35 { 36 // Area = 1/2 * a * b * sin(angle) 37 area = 0.5 * a[i] * b[i] * sin(angle[i]); 38 39 printf("%d\t\t%.2f\n", i + 1, area); 40 41 if (area > max_area) 42 { 43 max_area = area; 44 max_index = i + 1; 45 } 46 } 47 48 printf("\nLargest Plot is No. %d with Area: %.2f\n", max_index, max_area); 49 50 return 0; 51 }