Input 3 sides of a triangle and determine if it forms a right triangle or not


SUBMITTED BY: Guest

DATE: Oct. 12, 2013, 2:09 a.m.

FORMAT: C++

SIZE: 513 Bytes

HITS: 1250

  1. #include <stdio.h>
  2. int main()
  3. {
  4. int a;
  5. int b;
  6. int c;
  7. printf("\n Enter three sides of a triangle in any order : ");
  8. scanf_s("%d %d %d", a, b, c);
  9. if (a*a + b*b == c*c) || (b*b + c*c == a*a) || (a*a + c*c == b*b)
  10. {
  11. printf("\n %d, %d, and %d form a right triangle.", a, b, c);
  12. }
  13. else
  14. {
  15. printf("\n %d, %d, and %d DO NOT form a right triangle.", a, b, c);
  16. }
  17. getchar();
  18. getchar():
  19. return 0;
  20. }

comments powered by Disqus