bsc

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

lucproblem004.c (993B)


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