Files
college-C/3/ex2.c
2022-02-25 15:33:16 +02:00

56 lines
1.6 KiB
C

#include <stdio.h>
#define BOOLEAN unsigned short
#define TRUE 1
#define FALSE 0
#define ONE_HUNDRED_SIXTY 160
#define ONE_HUNDRED_FIFTY 150
#define FORTY 40
#define SIXTY 60
#define ZERO 0
#define MAX(a,b) a > b ? a : b
#define MIN(a,b) a < b ? a : b
//---------------------------------------------------------------------------------------
// Exercise 2
// ----------
//
// General : The program checks for the logical results of a championship game in
// the basket ball.
//
// Input : 2 numbers (results).
//
// Process : The program checks for the logical results by conditions.
//
// Output : '1' if is it True, '0' is false.
//
//---------------------------------------------------------------------------------------
// Programmer : Cohen Idan
// Student No : None
// Date : 19.09.2019
//---------------------------------------------------------------------------------------
void main(void)
{
unsigned short result1,
result2,
max_result,
min_result,
difference;
BOOLEAN answer = FALSE;
printf("Enter 2 numbers: ");
scanf("%hu%hu", &result1, &result2);
max_result = MAX(result1, result2);
min_result = MIN(result1, result2);
difference = max_result - min_result;
if ((max_result <= ONE_HUNDRED_FIFTY) &&
(min_result >= FORTY) &&
(difference <= SIXTY) &&
(difference > ZERO))
{
answer = TRUE;
}
printf("The answer: %hu\n", answer);
}