First Upload

This commit is contained in:
2022-02-25 15:33:16 +02:00
commit 0c74d10f0d
295 changed files with 74784 additions and 0 deletions

45
4/ex1.c Normal file
View File

@@ -0,0 +1,45 @@
#include <stdio.h>
#define BOOLEAN unsigned short
#define TRUE 1
#define FALSE 0
#define TEN 10
//---------------------------------------------------------------------------------------
// Exercise 1
// ----------
//
// General : The program checks if there is at least one common digit between 2 numbers.
//
// Input : 2 numbers.
//
// Process : The program checks check every digit of 2 numbers.
//
// Output : 0(FALSE), 1(TRUE).
//
//---------------------------------------------------------------------------------------
// Programmer : Cohen Idan
// Student No : None
// Date : 23.09.2019
//---------------------------------------------------------------------------------------
void main(void)
{
short num1,
num2,
temp_num1,
temp_num2,
digit_num1,
digit_num2;
BOOLEAN answer = FALSE;
printf("Enter 2 numbers: ");
scanf("%hd%hd", &num1, &num2);
for (temp_num1 = num1, temp_num2 = num2; temp_num1 && !answer;
(!temp_num2) ?
temp_num2 = num2, temp_num1 /= TEN:
(temp_num1 % TEN == temp_num2 % TEN) ?
answer = TRUE :
(temp_num2 /= TEN));
printf("The answer is: %hu\n", answer);
}