bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / letusc / lucproblem004.c

lucproblem004.c (857B)


      1 /* If the lengths of three sides of a triangle are entered through the
      2 keyboard, write a program to check whether the triangle is valid or not.
      3 The triangle is valid if the sum of two sides is greater that the largest
      4 of the three sides. */
      5 /* Let Us C, Chap - 4, Page - 66, Problem 4.3 */
      6 
      7 #include <stdio.h>
      8 int main()
      9 {
     10     double side1, side2, side3;
     11     printf("Enter the length of side1, side2 and side3 of the triangle : ");
     12     scanf("%lf %lf %lf", &side1, &side2, &side3);
     13     if (side1 <= 0 || side2 <= 0 || side3 <= 0)
     14     {
     15         printf("\nTriangle sides must be positive.\n");
     16         return 1;
     17     }
     18     if ((side1 + side2 > side3) && (side1 + side3 > side2) && (side2 + side3 > side1))
     19     // Triangle Inequality Theorem
     20         printf("\nThis triangle is valid.");
     21     else
     22         printf("\nThis triangle is not valid.");
     23     return 0;
     24 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror