fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int angle1, angle2, angle3;
  5.  
  6. // Prompt the user to input three angles
  7. printf("Enter the first angle: ");
  8. scanf("%d", &angle1);
  9. printf("Enter the second angle: ");
  10. scanf("%d", &angle2);
  11. printf("Enter the third angle: ");
  12. scanf("%d", &angle3);
  13.  
  14. // Check if the angles form a valid triangle
  15. if (angle1 <= 0 || angle2 <= 0 || angle3 <= 0) {
  16. printf("Error: The angles must be positive.\n");
  17. } else if (angle1 + angle2 + angle3 != 180) {
  18. printf("Error: The angles do not form a valid triangle.\n");
  19. } else {
  20. // Determine the type of triangle
  21. if (angle1 < 90 && angle2 < 90 && angle3 < 90) {
  22. printf("The triangle is Acute.\n");
  23. } else if (angle1 == 90 || angle2 == 90 || angle3 == 90) {
  24. printf("The triangle is Right.\n");
  25. } else {
  26. printf("The triangle is Obtuse.\n");
  27. }
  28. }
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0.01s 5264KB
stdin
 
stdout
Enter the first angle: Enter the second angle: Enter the third angle: Error: The angles must be positive.