Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //------------------------------------------------------------------------------------------------------------------------------
- // Exercise 4
- // ----------
- //
- // General : The program will get three angles and prints weather those angles are legal for a triangle or not. If they do, it will also print the kind of the triangle.
- //
- // Input : Three numbers that should represent triangle angles.
- //
- // Process : The program checks weather the sum of the angles is 180 and that they are above zero.
- //
- // Output : Prints if those are legal angles for a triangle, and the kind of the triangle.
- //
- //------------------------------------------------------------------------------------------------------------------------------
- // Programmer: Ohad Ozcohen
- // Date: 9.9.2016
- //------------------------------------------------------------------------------------------------------------------------------
- #include <stdio.h>
- #define sum_of_angels num1+num2+num3
- typedef char bool;
- #define TRUE 1
- #define FALSE 0
- void main(void)
- {
- float num1;
- float num2;
- float num3;
- char FLAG = TRUE;
- printf("Please enter the first angle: ");
- scanf_s("%f", &num1);
- printf("Please enter the second angle: ");
- scanf_s("%f", &num2);
- printf("Please enter the third angle: ");
- scanf_s("%f", &num3);
- if (sum_of_angels != 180 && num1>0 && num2>0 && num3>0)
- {
- printf("Cant be");
- FLAG = FALSE;
- }
- else
- {
- printf("Those are ilegal angles for triangle which is a ");
- }
- if (num1 < 90 && num2 < 90 && num3 < 90 && FLAG != FALSE)
- {
- printf("Sharp angle triangle");
- }
- if (num1 > 90 || num2 > 90 || num3 > 90 && FLAG != FALSE)
- {
- printf("Obtuse angle triangle");
- }
- if (num1 == 90 || num2 == 90 || num3 == 90 && FLAG != FALSE)
- {
- printf("Right triangle");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement